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.
I'm sorry for asking this question but I am very new to IM.
I have these PSD files(a lot of them) with Alpha channels and I want them to be converted into PSD files again but with transparent or white background.
How can I come up with this? I tried this command provided by the company but it is not working.
I cannot access your images because one needs to log-in and I do not have an account there. Can you post them so that one does not need a log-in or to some other public hosting service.
Your command looks like you ultimately want a jpg output. It would be easier to convert the PSD flattened layer [0] directly to jpg.
Does this work:
composite.exe -compose Dst_In -gravity center art.psd[0] art.psd[1] miff:- | convert.exe - -colorspace rgb -background white -gravity center -resize 1000x1000 -extent 1000x1000 -adaptive-sharpen 0 -quality 80 -strip art.jpg
Sorry about that command I just copy and pasted it without changing the output. But I really want it to remove the background from the psd file and output it again as a psd but with White background.
I tried your command but doesn't work. It still has a background of light gray and blue for the two images.
Your file has a fully opaque alpha channel according to identify -verbose 44-2868_11.psd. So the best I can do the convert it to transparent background is to change the blue color to transparent as follows using IM 6.9.9.26 Q16 Mac OSX.
There would be lots of psd files with different backgound on it. Is their a way to make it work on all of them?
I am very sorry. I am new to this and I don't have background on PS either.
The two PSD files have two different images. The images have the same object, but with different backgrounds. I think the task is to make an image that contains the object but with a blank (or white) background:
convert 44-2868_10.psd[0] 44-2868_11.psd[0] ( -clone 0-1 -compose
Difference -composite -fill White +opaque Black -negate ) -delete 1 -alpha off
-compose CopyOpacity -composite x.png
convert 44-2868_10.psd[0] 44-2868_11.psd[0] ( -clone 0-1 -compose
Difference -composite -fill White +opaque Black -negate ) -delete 1 -alpha off
-compose CopyOpacity -composite -background White -compose Over -layers Flatten
x2.png
Each command is one line. This is Windows CMD syntax. For bash, escape the parentheses \( and \).
For PSD output, change the output filenames to .PSD. (I can't test that.)
@snibgo, you're correct. I need to extract the object and make the background blank(or white) when converting the file. Your 1st command works great and it removes the background when converting to PSD file. But I noticed that you combined the two PSD files. When I try to use the same file using
convert 44-2868_10.psd[0] 44-2868_10.psd[0] and so on
it won't convert to transparent background anymore.
The attached files are just the sample files wherein the user will feed the system and convert it to blank or white background(whichever they want in the future). There are lots of PSD files with different background and I need them to work independent from each other.
Is there a command to extract the object that has alpha channel in it?
Each PSD file contains two images. The second is identical to the first. (At least, the two images that IM gets from the file are identical). All four images (two from each file) have an alpha channel, but it is fully opaque.
The command I showed need two images with identical foreground but different background. If you have images with transparent backgrounds, the task is far simpler.
Yes, it would be easier if the images has transparent backgrounds and that's what I'm trying to achieve. This is a really tricky task and I've spent so much time on this already.
Anyways, thanks for the help. But I need the images to work independently from each other. You solution works great but it is not applicable in my scenario. If you have any other solution to get the main object please let me know.
Okay, so you get single images from users, and want to remove backgrounds in general. That is possible if there is some way to distinguish background from foreground. In your "gray background" image, the foreground and background almost merge together towards the top-left. Separation is possible (find the slope magnitude; threshold at 1%; remove noise), but that method would probably not work on some other images.
I don't know a method that is guaranteed to remove any background. I think the best you can do is apply many methods, then choose the best result. There might be an automated method to choose the "best".
In your "gray background" image, the foreground and background almost merge together towards the top-left. Separation is possible (find the slope magnitude; threshold at 1%; remove noise)
Maybe this is possible. Do you have a script or command for this Separation thingy?