I am doing the standard image optimise / resize technique with PHP and GD, basically:
imagecreatefromjpeg()
imagecreatetruecolor()
imagecopyresampled()
imagejpeg()
However people are complaining that there CYMK logos are coming up different colours after being uploaded. I know this is because GD is doing a conversion to RGB but i am wondering if there is a way to improve this?
As these are often peoples logos, they rightly get protective over the colours used and want them to be right.
I know there are some good tools to convert single colours online but i want something that can be added to my class file that converts all the CMYK colours in an image to a more accurate version of the CMYK equivalent.
As a quick example, a pic uploaded without conversion and then selected with a colour picker extension in chrome gives me this HEX code: #992A78. Having run it through the above scripts, it converts it to this one: #9000F6;
Anyone got any advice for me? Thanks
GD doesn't support color management at all, which explains the color shift, so there is probably no feasible workaround there. You might want to do some quick tests using ImageMagick, which seems to support various color profiles.
Related
Please accept my apologies if this question is a duplicate - I have spent several hours trawling the internet for the answer - part of the issue is I am uncertain if -colorspace and -depth are all I need to acheive my goal.
Essentially we have a process which needs to ensure that all files sent to it have some standard consitencies. Currently the file is opened in Photoshop, the image mode is set to RGB Color and 8 Bits/Channel and any empty transparent parts of the PNG are trimmed.
I am now attempting to do this programatically to save time.
convert TEST-16BIT.png -depth 8 TEST-8BIT-DEPTH.png
This successfully changes the file to 8bit from 16bit with no noticeable changes in the files appearance.
However using -colorspace is causing the grey to turn black ragardless or wether the image mode was already RGB or CMYK. From the research I've done - this appears to be what I should be using?
So my question is have I misunderstood the nature of colourspace and this isn't the correct use for it - or do I infact need to use with some additional options that I havn't thought of?
Any suggestions would be really appreciated.
All commands have been run using ImageMagick 6.9.11
I'm struggling with generating high-quality images for printing - mainly because there is really poor support for CMYK colors in PHP libraries and Linux CLI tools.
The situation is as follows. I have input materials in tiff format and CMYK colors - it is the background. I need to add some text to it and save as tiff with CMYK colors. The challenge is to use exact CMYK colors (so no temporary export/import to sRGB during the process is possible).
My first thought was to use Imagemagick but Imageimagick has no option to draw in CMYK. I need to work in sRGB and export material to CMYK. So some information about colors are changed during the process.
It seems this is not possible with PHP to add text to image without temporarily converting colors to sRGB, so I'm looking for any option like Linux CLI tool, node.js lib, etc. The goal is to at least generate text as an image with a transparent background and with colors defined in CMYK with exact values or do the same directly on the background image.
Finally, I gave up with Imagemagick. As we can use PDF for professional printing I decided to go this way.
I installed TCPDF and TCPDI. With TCPDI I imported previously prepared pdf template with graphics etc. Using TCPDF I added necessary dynamic text - TCPDF support CMYK with no issues.
Depending on where you print you can embed fonts to PDF (it can be done with TCPDF) or change texts to outlines which is a small challenge. I needed to change fonts to outlines (client request) so I did it with Ghostscript.
It took me a whole day to figure it out, so I post it in case somebody will have a similar problem. Definitely not an answer to the question, but at least a good solution for the problem itself.
Is it possible with PHP GD to skew/distort images on both sides ?
I already check other question/solution but I really don't understand how to move all the corners of the image.
What I need is transform a flat image to a distort image moving all 4 corners, something like if you use Adobe Photoshop transform distortion function that allows to move single corner to a new position.
Is it possible ?
Many thanks in advance.
Bye
It can be done with the help of the QB extension.
In theory, it's possible to accomplish the same thing using just the built-in GD functions. It'd be agonizingly slow though.
This might seems like a duplicated question, but I couldn't find exactly this scenario. Might be wrong though.
My problem is, say I have a square, $square, of 100x100 pixels inside a canvas of 150x150. Background is transparent.
I cloned the square and then I cropped the part I needed to work on ($detail).
I need to apply a gradient, top to bottom, on $detail so that the top part is around 60% white-transparent to a 100% transparent at the bottom.
Then, to compose $detail over $image.
I can't use convert, only php imagick functions.
Thanks in advance!
Will
convert has a special creation operator in recent versions for producing gradients, simply called gradient: - they are implemented as pseudo image formats.
Usage of the gradient: operator can get quite complex if you want non-vertical gradients or with transparency, so read the documentation. Be aware the underlying version of Image Magick will make a difference to how you have to go about it.
You can create pseudo-format images, using the IMagick operator: Imagick::newPseudoImage()
Once you have the gradient at the right size, you can compose it with your $detail image.
Generally, my tip with using things like IMagick, is to get the command right using convert first and then translate it to the interface.
So I'm in the middle of working on a website that deals with photographs. A user uploads their original photograph and GD library creates a smaller sized image of the same photo. However, when comparing a manually sized down image with the GD one, the GD image seems to lose quite a bit of color quality like it had been slightly desaturated. Any alternate suggestions or ways to improve this?
Thanks!
I'd advice using imagemagick for handling anything serious about photos.
besides quality, you'll find using imagick functions like more convenient
Imagick::cropThumbnailImage()
Imagick::thumbnailImage()
Use imagecopyresampled instead of imagecopyresized. It gives much better quality. Also, try NOT to use GIF images as output.
Wow, the answer is imagemagick. Easier to use and maintains the full photograph quality!