The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

photo auto-resizing hack (9 posts)

  1. neb_orbit_greely
    Posted 13 years ago #

    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:
    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,

  2. isaacwedin
    Posted 12 years ago #

    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

  3. neb_orbit_greely
    Posted 12 years ago #

    Cool, I'd like to see it.

  4. neb_orbit_greely
    Posted 12 years ago #

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

  5. Alex King
    Posted 12 years ago #

    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.

  6. Matt Mullenweg
    Posted 12 years ago #

    Well that's a pretty high bar to set.

  7. isaacwedin
    Posted 12 years ago #

    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.

  8. Alex King
    Posted 12 years ago #

    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.

  9. neb_orbit_greely
    Posted 12 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.