• Hi,

    Hope someone could help me out. I’m building a photography website, thus image quality is very important.

    I’ve set up new image sizes:

    add_action( 'after_setup_theme', 'ph_custom_image_sizes' );
    function ph_custom_image_sizes() {
    	add_image_size( 'ph-project-large', 9999, 640, false );
    	add_image_size( 'ph-project-medium', 640, 580, false );
    	add_image_size( 'ph-admin-thumb', 360, 360 );
    }

    I was hoping that wordpress wouldn’t generate additional image files, if the file uploaded would have the same width or height, as stated in the code reference webpage for add_image_size function. That way, I could control image size and quality.

    Thing is, wordpress is creating additional files, even when width or height are the same the new image size. And it drastically reduces size (which wouldn’t be so bad), but also reduces quality (which for me is a problem).

    Example: Uploading an image of 960×640 (exampleimage.jpg) generates a new file with the exact same resolution (exampleimage-960×640.jpg).

    Any thoughts why this is happening?

    Thanks so much for any guidance you could offer ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    take a look here:

    https://premium.wpmudev.org/blog/fix-jpeg-compression

    It explains how to write a filter that stops WP from compressing your images.

    Thread Starter diogobento

    (@diogobento)

    Thank you! Great resource!
    Haven’t tested it yet, but seems like it will solve this issue.

    Anyway, as a developer I would still like to understand why was wordpress still generating new files. Was this something removed from newer versions?

    Cheers.

    Thread Starter diogobento

    (@diogobento)

    Just tested and still doesn’t work as expected. WordPress still generates new files, this time the new file being heavier than the original one!

    Actually, JPEG always compresses files on save, even at 100%. I guess that’s what’s happening here. This snippet doesn’t stop wordpress auto-compression, it just makes wordpress compress the new image at 100%.

    What I am looking for is a way for wordpress to use the original file, without any kind of compression or manipulation; just a plain copy of the original file.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WordPress generating new image file with same width and height of original image’ is closed to new replies.