Wednesday, May 1, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 4435  / 3 Years ago, tue, august 24, 2021, 11:53:30

I have a folder of png files that have transparent backgrounds. I would like to convert them from the command line and maintain the images' transparent backgrounds.



I'd appreciate any help.



Since jpgs don't support transparency so how can I specify the output jpg's background color's hex value? Right now it defaults to #ffffff? I have tried this script, but it gives the output jpgs white backgrounds:



mogrify -quality 100 -format jpg *.png


Update



I created these png files in inkscape. I should mention that my goal in converting these pngs to jpgs is to get rid of jagged edges on circular or angular objects. The pngs currently have jagged edges and I read that converting them to jpgs might solve this problem. However converting via the method outlined in Christian Skjødt's answer gives the images even worse jagged edges. Is there a way that I can convert the pngs to jpg and also use anti-aliasing or maybe another technique to get rid of the jagged edges? Thanks for the help.


More From » command-line

 Answers
5

To smooth the edges you could create the PNGs 10x larger than your target size, then resize with anti-aliasing to JPG. I have done this using Python and the Python Imaging Library to good effect, but I'm not sure how to do it using other tools.


[#43724] Wednesday, August 25, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fulerio

Total Points: 172
Total Questions: 124
Total Answers: 109

Location: Hungary
Member since Thu, Aug 6, 2020
4 Years ago
;