2

The right half of the image is how it appears in Photoshop. To the left is the color cast that is being applied once the image is uploaded via PHP.

For photo processing, I'm using Photoshop's "Save For The Web" .jpg function, and on the development end, I'm using pretty straightforward PHP image upload functions.

The odd thing is that only certain colors– most noticeably green– are being misinterpreted. Black and white photos aren't getting any color cast, and images with less green are hardly different.

The same image file looks as desired on Facebook, etc. That leaves me wondering if it's a matter of somehow saving my images in a more universal way, or resolving some kind of flaw in the configuration of the uploading functions.

I've been able to find very little information on either possibility. For those with knowledge of PHP and/or Photoshop, any idea how to resolve this? The website is focused on agriculture, so there'll be a whole lot of green!

FYI I am using a 3rd party PHP image upload script called SimpleImage. It's about as basic as it gets, and there's no indication to me that the script is set to manipulate color outputs. http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/

Thank you Michael Femia

RESOLUTION: Matt brought to my attention that if a color profile is not set in Photoshop's save for the web function, some issues may occur. It turns out that checking sRGB resolved the issue of a color cast being applied to the uploaded image.

Beyond making sure a color profile is specified in Photoshop, my resolution as recommended by Yohann and Wrikken, will also involve discontinuing use of the basic PHP GD functions, and shifting over to the ImageMagick library, which is a great deal more robust, and appears to deliver much higher quality.

Excellent PHP image upload thread shared by Yohann: How to stop GD2 from washing away the colors upon resizing images?

PHP/ImageMagick Documentation: http://www.php.net/manual/en/book.imagick.php

PHP/Imagick Processing Tutorial I found helpful:http://www.sitepoint.com/crop-and-resize-images-with-imagemagick/

Community
  • 1
  • 1
  • _what_ are you doing with it in PHP? (fixed your link BTW). If it's just an upload, the image is as is (nothing to do with PHP then). If you just look at it in a browser, and also your local image in the browser, they should be the same, or something does some processing on it in between. – Wrikken Mar 15 '14 at 19:45
  • I'm using a third party function called SimpleImage (link below). http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/ It determines the size and file type, then uses imagecreatetruecolor() I don't see any indication that the color outputs are being manipulated, and like I said, the only issue is with greens. Sorry I didn't catch what you mean by fixing my link-- can you not view the image? – Michael Femia Mar 15 '14 at 20:01
  • Ahh thank you for fixing the URL. Did not realize that extra directory snuck in. – Michael Femia Mar 15 '14 at 20:06
  • 1
    Maybe the answer here http://stackoverflow.com/questions/5773032/how-to-stop-gd2-from-washing-away-the-colors-upon-resizing-images? – Yohann Tilotti Mar 15 '14 at 20:15
  • Well, GD has its quircks. That resizer doesn't seem that bad, but the '75' for quality default is a bit iffy. You could try what happens if you just set that to 100. In my mind though, the question is now: you are crafting a 'perfect' picture in Photoshop, which is terribly good at what it does. If this just for yourself on a website, why even let GD _touch_ the thing? Upload the picture in the right dimensions and you're done. However, if this is more an end-user oriented upload that has to work well: you could try if imagemagick does a better job. – Wrikken Mar 15 '14 at 20:18
  • Wrikken–I should've elaborated: multiple non-web savvy users will be contributing content, so the reasons I'm using a PHP upload script are 1: to avoid having large straight-from-the-camera images all over the place (they don't have Photoshop), and 2: to resize to a few different sizes for thumbnails and more efficient full-size display on various devices. – Michael Femia Mar 15 '14 at 20:25
  • Yohann & Wrikken, after taking a look at ImageMagick, I think that's the route I'm going to take. Thank you for pointing it out! It looks beautiful! – Michael Femia Mar 15 '14 at 20:26
  • In Photoshop's "Save for the Web" dialog, are you choosing "Convert to sRGB"? If not, try that. It's likely that an embedded colour profile in the images is causing the issue. – Matt Gibson Mar 15 '14 at 21:28
  • Matt, that did the trick on the color cast! Turns out sRGB was unchecked. However, I think I'm still heading toward ImageMagick just because it seems like it's more capable of handling whatever my users will throw at it, and maintaining a higher quality with a comparable file size. Overall seems like a better guarantee of quality from what I've seen so far. Any thoughts on this? (I'll update my post to reflect that specifying a color profile resolved the color cast) – Michael Femia Mar 15 '14 at 21:43
  • @MichaelFemia I'd say that if ImageMagick is automatically converting -- or could be told to convert -- uploaded images' colour profiles to sRGB, then it should help to keep your image colours looking as expected across different browsers (some of which respect embedded colour profiles, some of which don't.) So assuming that's the case, going with ImageMagick seems sensible. (Also, it may help you cope with the other bane of image uploads at the moment, the EXIF rotation metadata, which again, some browsers cope with, and some don't...) – Matt Gibson Mar 16 '14 at 17:58

0 Answers0