Page 1 of 1

Convert the background of an image to transparent

Posted: 2017-04-05T07:23:31-07:00
by laxmi131
hello All,
I want to perform 3 steps in a single convert comaand

1. convert the image from CMYK to RGB
2. convert the background of a image to transparent
3.convert image to png.

Code: Select all

convert  -profile <path>\CoatedFOGRA27.icc -profile <path>\sRGB_v4_ICC_preference.icc -resample 300x300 -depth 8 "%1"[0] -fuzz 10% -transparent white -flatten -resize 1260x1260 -quality 80 "%2"
I also tried below command:

Code: Select all

convert  -profile <path>\CoatedFOGRA27.icc -profile <path>\sRGB_v4_ICC_preference.icc -resample 300x300 -depth 8 "%1"[0] -background none -flatten -resize 1260x1260 -quality
80 "%2"

I am able to convert the image to RGB and also generate a .png file but using the above script background is not converted to transparent. Can you please let me know the Imagemagick script for converting the background. the source file which I am using is a .eps

Thanks in advance.

Re: Convert the background of an image to transparent

Posted: 2017-04-05T07:50:56-07:00
by snibgo
What version IM do you use? On what platform? If Windows BAT, you should double the % in "-fuzz 10%".

The correct syntax is: read the image; process it; write the output. So the "profiles" and "-resample" should be after the input file, not before it.

After the resample, what colour is the background? You want to make that colour transparent, yes? If it was white, than "-transparent White" will do that.

Why do you "-background none -flatten"? What does that do?

Re: Convert the background of an image to transparent

Posted: 2017-04-05T19:15:15-07:00
by fmw42
User snibgo has some good points. Furthermore ...

Perhaps you should post one of your input images? What format is it? Is it transparent or not? Why do you do -resample and also -resize? You should do just one or the other. You can do -resize alone and then set the density you want, if you want a certain pixel dimension and a certain print size.

Re: Convert the background of an image to transparent

Posted: 2017-04-05T22:36:54-07:00
by laxmi131
Hi
Thank you for responding , we use "ImageMagick-6.6.9-Q16". I use this imagemagic script in media manger. this script is defined in a pipeline of media manger and hence I have not specified the input and output file. my input file will be .eps and the output file will be .png . media manager pipeline take caes of converting the image from .eps to .png .

The output image should be of 300 dpi ( for that I used -resample 300x300) , image should have size 1260x1260 ( for that I used -resize 1260x1260). also used -profile for converting CMYK to RGB.

My input image has a white background . and i want to convert the background to transparent, which is not happening :(

can you please give me a script which can perform all the above i.e , cmyk to rgb, dpi 300, size 1260x1260, transparent background

Re: Convert the background of an image to transparent

Posted: 2017-04-05T23:14:17-07:00
by fmw42
Try using the proper IM syntax:

Code: Select all

convert yourimage[0]  -profile <path>\CoatedFOGRA27.icc -profile <path>\sRGB_v4_ICC_preference.icc -fuzz 10% -transparent white -resize 1260x1260 -density 300x300 -quality 80 outputimage
If that does not work, then please provide an example input image.

If the output is JPG, note that JPG does not support transparency. If the output is PNG, then -quality means something different and its values are not simply 0-100. See http://www.imagemagick.org/script/comma ... hp#quality

I have a feeling that your input may be either PSD or TIFF. It would be best to provide an example image.

Re: Convert the background of an image to transparent

Posted: 2017-04-06T01:51:09-07:00
by laxmi131
Hi I tried the IM syntax which you mentioned. but that did not work.
I see that I don't have an option to attach my input file , please let me know the option where I can attach my input an output image

Re: Convert the background of an image to transparent

Posted: 2017-04-06T02:12:03-07:00
by snibgo
You can upload to somewhere like dropbox.com and paste URLs here.

Re: Convert the background of an image to transparent

Posted: 2017-04-06T06:49:11-07:00
by laxmi131

Re: Convert the background of an image to transparent

Posted: 2017-04-06T07:50:03-07:00
by snibgo
The image has an embedded profile, so we don't need your first CMYK profile.

Code: Select all

convert input.eps -profile sRGB.icc -transparent White -resize 1260x1260 -density 300 -units PixelsPerInch -depth 8 x.png
This works fine for me, IM v6.9.5-3.

Re: Convert the background of an image to transparent

Posted: 2017-04-07T06:47:21-07:00
by laxmi131
Hi,
the script worked but the backgroung which is am looking is for transparent and grid. not sure how it can be done ,
sorry for the trouble I am new to image magick.

input -- https://www.dropbox.com/s/9fx0dxt2mpae6 ... t.eps?dl=0

my output should look like the below specified in the ink
https://www.dropbox.com/s/0xpfr785cirzz ... 2.png?dl=0

Thanks

Re: Convert the background of an image to transparent

Posted: 2017-04-07T07:03:18-07:00
by snibgo
I'm confused. Do you want a transparent background? Does my command give you a transparent background?