Page 1 of 1
JPEG to PNG - Transparent Background
Posted: 2014-07-06T15:25:56-07:00
by jamesprivett68
Hi
I have around 1700 JPEG images that have a white background. I would like these converted to PNG images with a transparent background. None of the images have any white in the actual picture itself, just the back ground.
Looking through various forums and websites, I believe this can be done pretty easily and quickly with ImageMagick using something like
convert -transparent white whatever.jpg whatever.png
I haven't got Microsoft Visual Studio installed and once these 1700 images are converted, will not have any further need for more advanced image conversion techniques (I was producing images in Illustrator for my website, but saving them in JPEG rather than PNG). Anything produced going forward will be saved in the PNG format.
I can do this 1 at a time as I have the original AI files to work from, but if it is possible to do this in a batch, it would save hours and hours of time.
Any advice or help would be appreciated
Thanks
James
Re: JPEG to PNG - Transparent Background
Posted: 2014-07-06T15:39:20-07:00
by snibgo
[Mod note: the consultancy forum is for paid consulting, which this doesn't seem to be, so I've moved this to Users.]
Have you installed ImgeMagick?
What is your platform? From your reference to Microsoft Visual Studio, perhaps Windows?
Your command should do the trick. If your background isn't exactly white, try a fuzz.
Re: JPEG to PNG - Transparent Background
Posted: 2014-07-06T15:47:16-07:00
by jamesprivett68
Hi, I have not installed ImageMagick as from what I understood from the website, it requires Microsoft Visual Studio to be installed, which I have not got.
My platform is windows.
The majority of my work in done using CorelDraw X6, Illustrator CS6 & AutoCad 2014. I don't believe I have a future need for Visual Studio and cannot warrant paying out £300 or so for this 1 requirement.
I am willing to pay for the conversion of these files if someone can pick them up from my dropbox, convert them and then drop them back
Re: JPEG to PNG - Transparent Background
Posted: 2014-07-06T16:07:49-07:00
by snibgo
Unless you want to compile it yourself, you don't need anything else, for Windows. On page
http://www.imagemagick.org/script/binar ... hp#windows , follow the instructions. It takes about 5 minutes, depending on how fast your internet is.
Re: JPEG to PNG - Transparent Background
Posted: 2014-07-06T16:31:43-07:00
by jamesprivett68
Thanks, got it installed and ran a conversion that worked perfectly.
Wondering if you could assist with a couple of things? I have found the below script that should help me batch convert
for img in *.jpg; do
filename=${img%.*}
convert -transparent white "$filename.jpg" "$filename.png"
done
However, I'm not sure if I am meant to type this is the command prompt of somewhere in imagemagick?
Basically, all my files are named something like 001-A-RED, 001-A-YEL, 056-A-RED
so they all have A in the file name or (which I guess is easier) they all appear in the same directory
Re: JPEG to PNG - Transparent Background
Posted: 2014-07-06T16:50:23-07:00
by snibgo
Only the "convert" part is ImageMagick. The rest is Unix.
For Windows, type this at the command prompt:
Code: Select all
for %F in (*.jpg) do convert %~nF.jpg -transparent white %~nF.png
JPEG files normally have a .jpg extension. If yours don't, then leave off .jpg in the command.
Re: JPEG to PNG - Transparent Background
Posted: 2014-07-06T17:16:10-07:00
by jamesprivett68
Excellent, works perfectly. Thanks for you help on this, saved me a good weeks work with this automated process
Re: JPEG to PNG - Transparent Background
Posted: 2014-07-06T17:19:34-07:00
by jamesprivett68
Sorry, one last question and it probably doesn't matter too much.
Because the drawings are all pretty basic, in Illustrator I was saving these PNG-8. When I convert these files, they seem to have a Bit depth of 32 rather than 8.
Is it possible they can be converted to PNG-8 to try and keep the file size down or is this going to be a bit more complex?
Re: JPEG to PNG - Transparent Background
Posted: 2014-07-06T17:24:33-07:00
by fmw42
Re: JPEG to PNG - Transparent Background
Posted: 2014-07-06T17:50:14-07:00
by snibgo
As Fred says, use "PNG8:". If your filenames have spaces in them, you should also use quotes, thus:
Code: Select all
for %F in (*.jpg) do convert "%~nF.jpg" -transparent white png8:"%~nF.png"
Re: JPEG to PNG - Transparent Background
Posted: 2014-07-06T18:16:30-07:00
by jamesprivett68
Thanks, appreciate all your help on this