Support » Plugins » photo auto-resizing hack

  • 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)
  • 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

    Thread Starter neb_orbit_greely

    (@neb_orbit_greely)

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

    Thread Starter neb_orbit_greely

    (@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.

    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.

    Well that’s a pretty high bar to set.

    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.

    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.

    Thread Starter neb_orbit_greely

    (@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.