Thursday, May 2, 2024
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 820  / 2 Years ago, thu, july 14, 2022, 1:23:26

I have couple of images that are of 32MBs of size and I want to change their size from 32MBs to 100Kbs or any KBs of size without affecting its colours.


The commands I am trying are:


muhammad@muhammad-mohsin:~/scans$ find . -iname '*.png' -exec mogrify -format jpg "*.png" {} +


muhammad@muhammad-mohsin:~/$ find . -type f -iname *.png -delete


muhammad@muhammad-mohsin:~/$ find . -iname '*.jpg' -exec mogrify -define jpeg:extent=300kb -strip -quality 90 -scale 90% *.jpg {} +

Here, first I convert a PNG to JPG that reduce its size from 32Mbs to 5.8Mbs and everything stays same but when I use 3rd command, it removes background color in image and making it grayscale sort of blurry.


However, the text is still readable but colors and background logo does not.


How I can achieve this with convert, mogrify or any other tool? I tried every possible thing so far.


This is part of original image


This is part of changed image after command


More From » image-processing

 Answers
0

I am trying find . -iname '*.png' -exec convert -resize 60% -quality 60 "*.jpg" {} + but that does not work.



Ref. https://superuser.com/questions/71028/batch-converting-png-to-jpg-in-linux


$ ls -1 *.png | xargs -n 1 bash -c 'convert -quality 60 "$0" "${0%.*}.jpg"'

Converts my example 31MB.png to 1.4MB.jpg . ... You may have to repeat with e.g. $ ls -1 *.PNG | ... etc.


Ref. comment by @steeldriver : "slightly better is xargs -d '
' -n 1
"


[#1277] Saturday, July 16, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
strhen

Total Points: 27
Total Questions: 111
Total Answers: 103

Location: Angola
Member since Tue, Apr 25, 2023
1 Year ago
strhen questions
Sun, Jun 6, 21, 04:57, 3 Years ago
Tue, Mar 1, 22, 12:44, 2 Years ago
Wed, Jul 21, 21, 14:38, 3 Years ago
;