Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Utilizing IMagick commands, we are running some thumbnail commands on .psd, .eps, and .jpg files to convert them to .png. However, some of the images are giving us a problem where the black color becomes an odd aqua color. I have an image example of before:
And once the command is run, it turns in to the following image:
$thumb=new Imagick($local_path);
$thumb->flattenImages();
//Scale the image
$thumb->thumbnailImage(128,128,true,false);
$thumb->setImageFormat("png");
$thumb->stripImage();
//Write the new image to a file
$thumb->writeImage('/home/metathumbs/'.$image_data->thumb);
$thumb=new Imagick($local_path);
$thumb->flattenImages();
$thumb->setImageColorspace(Imagick::COLORSPACE_SRGB);
//Scale the image
$thumb->thumbnailImage(128,128,true,false);
$thumb->setImageFormat("png");
$thumb->stripImage();
//Write the new image to a file
$thumb->writeImage('/home/metathumbs/'.$image_data->thumb);
The problem is that this is part of a script that cycles through a MySQL database, and some of the files are .eps files, some are .psd files, and some are .jpg files. I never know which is which. So, I would have to write a try >> catch statement, or if >>> then statement to test the extension of each file, which is fine, I can do that. However, I cannot have the background's be white, they MUST be transparent. The files change, and new files are added. There are over 40,000 images that this script can run through, not knowing which extension it is going to be.
The file must be an exact replica of the .eps/.psd/.jpg file it is originating from. If it is not exact, the client will continue to wonder if it is the appropriate image. High-maintenance client this is.
Using the latter generates three images, but the last one is all white.
You will need to put in your path to your profiles after you locate some.
As I stated before, this is in PHP, so I need the PHP command to utilize the convert command. I will continue to search for it, but have had no luck so far. I have the profiles I need.
convert: unable to open image `/usr/include/ImageMagick/Profiles/RGB Profiles/sRGB.icc': No such file or directory @ blob.c/OpenBlob/2480.
convert: missing an image filename `/home/metathumbs/HON_SteelBookcases_Group.png' @ convert.c/ConvertImageCommand/2800.
45450 HON_SteelBookcases_Group.psd HON_SteelBookcases_Group.png
If you are having problems start with something simple ( for instance everthing in the same directory as the code ) and when it works then use variables etc.
webdevsoup wrote:Ok, I was able to convert the image using direct paths. However, the image still does not appear black, although it's extremely close.
Can it get closer? If not, I'll begin substituting variables for my images.
Also, I noticed for this particular image, I actually get 4 .png files. I need it to be 1 .png file. How do I get rid of the others?
PSD files can have multiple layers. Usually the first layer is the flattened image. But you can select any layer Try
image.psd[0] in your code to select the first layer.