WordPress.org

Support

Support » Plugins and Hacks » photo auto-resizing hack

photo auto-resizing hack

  • neb_orbit_greely
    Member

    @neb_orbit_greely

    Hi,
    I made up a simple auto image resizing hack.
    This code requires ImageMagick installed on your server.
    What it does:
    If you upload a JPEG image that is greater than 600 pixels wide (or whatever width you choose) this will automatically resize the image. Additionally it will jpeg compress the image (to the jpeg compression setting you choose) and it will add the image width/height into the tag for you.
    It makes changes only to the file /wp-admin/b2upload.php
    Here’s some directions/source:
    http://www.ideacog.net/wordpress
    This code most likely works with PNG and GIF images as well, I just haven’t tried it.
    Feel free to post feedback, etc.
    Good luck,
    Ben

Viewing 8 replies - 1 through 8 (of 8 total)
  • isaacwedin
    Member

    @isaacwedin

    This is exactly what I’ve been looking for! My host doesn’t seem to have ImageMagick though so I swapped in some code to use GD instead. If anyone’s interested let me know.
    isaac at wedin dot org

    neb_orbit_greely
    Member

    @neb_orbit_greely

    Cool, I’d like to see it.
    -Ben

    neb_orbit_greely
    Member

    @neb_orbit_greely

    I’ve heard that — but is there no way to not compress the image if you resize it? That seems a shame.

    Alex King
    Member

    @alexkingorg

    I don’t mean the compression, I mean the resizing algorithm (the compression is also a problem, but that is configurable). It just doesn’t look nearly as good as the results I get from Photoshop.

    Matt Mullenweg
    Keymaster

    @matt

    Well that’s a pretty high bar to set.

    isaacwedin
    Member

    @isaacwedin

    The quality seems to depend on the version of GD you’ve got to work with. I have 2 so I can use imagecreatetruecolor and imagecopyresampled instead of imagecreate and imageresized. Imagejpeg takes a quality setting so you can adjust the compression of the output file to suit. The results seem good to me, but I’ve set it up to resize them pretty small. I’m using it at wedin.org to turn users’ giant uploads into thumbnails linked to smaller images.
    Here’s a link to my modified b2upload.php. Sorta messy, no guarantee it’ll work for you, and so on. I’d love to hear any suggestions for improvements.

    Alex King
    Member

    @alexkingorg

    I haven’t tried imagecopyresampled() – I’ll give that a shot. I’d love it if I could get good quality results from GD.
    Yes, Photoshop may be a high bar to set, but quality is quality and it is the bar nonetheless.

    neb_orbit_greely
    Member

    @neb_orbit_greely

    Hi Del,
    Thanks.
    Configuring the size wouldn’t be so hard at runtime. I’ll add that in when I get a chance.
    -Ben

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘photo auto-resizing hack’ is closed to new replies.