How to enlarge into PNG no less than a height of 2880, but proportions must be sustained and maintained? - imagemagick

My special requirements are,
When their height is 2879 or below, enlarge into 2880
When their height is 2881 or over, leave alone
Always sustain and maintain their proportion
Everything must be converted into PNG in a full quality, no matters if the source picture is PNG or JPG
Those are my photographes to be enlarged for use as my own UEFI wallpapers on an 5k screen
PNG source pictures to be overwritten by the results
JPG source pictures to be removed after the final completion
Finally, i’m unsure if those below commands are correct for doing everything above,
for J in *.jpeg; do ls */*|grep jpeg|xargs -I $J mogrify $J -gemoetry x2880< -quality 100% $J.png; done
for j in *.jpg; do ls */*|grep jpg|xargs -I $j mogrify $j -gemoetry x2880< -quality 100% $j.png; done
for K in *.JPEG; do ls */*|grep JPEG|xargs -I $K mogrify $K -gemoetry x2880< -quality 100% $K.png; done
for k in *.JPG; do ls */*|grep JPG|xargs -I $k mogrify $k -gemoetry x2880< -quality 100% $k.png; done
find ./ -type f -iname "*.JPEG" -exec mogrify -format png -layers Dispose -gemoetry x2880< -quality 100% {} +
find ./ -type f -iname "*.JPG" -exec mogrify -format png -layers Dispose -gemoetry x2880< -quality 100% {} +
find ./ -type f -iname "*.jpeg" -exec mogrify -format png -layers Dispose -gemoetry x2880< -quality 100% {} +
find ./ -type f -iname "*.jpg" -exec mogrify -format png -layers Dispose -gemoetry x2880< -quality 100% {} +
Thanks answering anyway, i appreciate every people’s effort :)

Related

Use Imagemagick to crop large images to a specific aspect ratio and then resize them

I have a bunch of high-resolution images from Unsplash and,
First need to crop to a 16:9 aspect ratio (from the center), and then,
Resize them to 2560x1440px.
How do I do this using Imagemagick on a Mac?
I think this will do what you need for a single image:
magick INPUT.JPG -gravity center -extent 16:9 -resize 2560x1440 RESULT.JPG
If you want to do lots, you could use a bash loop:
for f in *.jpg *.png ; do
magick "$f" -gravity center -extent 16:9 -resize 2560x1440 "$f"
done
If you have thousands, you could use homebrew to install GNU Parallel with:
brew install parallel
Then get them done in parallel using all your CPU cores with:
parallel --bar magick {} -gravity center -extent 16:9 -resize 2560x1440 {} ::: *.jpg *.png
If you have hundreds of thousands, or millions, that will overflow the ARG_MAX, so you will need to feed the filenames on stdin like this:
find . -iname \*.png -print0 | parallel -0 magick {} -gravity center -extent 16:9 -resize 2560x1440 {}

Convert PDF to Image(s) with different resolution using ImageMagick

I have to convert the pdf file (with more text) to images with different resolution.
I am executing the following commands:
width:1024px
convert -density 150 -antialias -resize 1024x -quality 80 "${inputFilePath}" "${outputFilePath}"
width:720px
convert -density 150 -antialias -resize 720x -quality 80 "${inputFilePath}" "${outputFilePath}"
width:320px
convert -density 150 -antialias -resize 320x -quality 80 "${inputFilePath}" "${outputFilePath}"
The generated images are not clear.
Can you help me to understand what I have to change?
Thanks in advance.
Increase your density to get better quality. -antialias will not help in your ImageMagick command. It is only used when adding new text. Put the density after convert and then put the input. Put your quality after the input and before the output. Use parenthesis processing with clones to generate all 3 results in one convert command.
convert -density 300 input \
\( -clone 0 -resize 1024x -quality 80 +write output1 \) \
\( -clone 0 -resize 720x -quality 80 +write output2 \) \
\( -clone 0 -resize 320x -quality 80 +write output3 \) \
null:

Generate thumbnails for only the first frame of animated gif with mogrify

How to modify this code so mogrify will generate thumbnails only for the first frame of animated gifs?:
mogrify -resize 80x80 -background white -gravity center -extent 80x80 -format jpg -quality 75 -path thumbnails *.gif
The select frame notation would be [N] immediately after the filename; where N is the frame number you wish to select. See Selecting Frames section under the input filename examples.
mogrify -resize 80x80 \
-background white \
-gravity center \
-extent 80x80 \
-format jpg \
-quality 75 \
-path thumbnails \
*.gif[0]

ImageMagick change all images to preset size with DPI

Trying to use imagemagick to have all images set to a preset size like a letterhead (8 1/2x11) for example... id prefer to not use resize and trying to get them to a 100 dpi setting... Im personally not very good with imagemagick and after 2 days of searching around Ive got it mostly complete?
for f in `ls *jpg`; do
convert -compress Group4 -type bilevel \
-depth 100 -units PixelsPerInch \
-monochrome -resize 850X1100 $f 2-$f;
done
Anyone have any further pointers on this?
You would use -density option to set the DPI.
for f in `ls *jpg`
do
convert -compress Group4 \
-type bilevel \
-depth 100 \
-units PixelsPerInch
-monochrome \
-resize 850X1100 \
-density 100 \
$f 2-$f
done
You can verify by using the identify utility.
identify -format "%x x %y" some_image.jpg
Edit:
As Birei pointed out. You can use "*.jpg" wildcard to iterate over the files in a directory, and quoting the output file name would be important for file names with spaces. You can use Filename Percent Escapes to create & preserve source image information.
convert *.jpg \
-compress Group4 \
-type bilevel \
-depth 100 \
-units PixelsPerInch
-monochrome \
-resize 850X1100 \
-density 100 \
-set filename:f '%f' \
'2-%[filename:f]'
The -set filename:f '%f' will preserver the original file name w/ proper escaping, and '2-%[filename:f]' will write the 'f' value with custom prefix '2-'. No need to use Bash for-loop.

ImageMagick: How to resize proportionally with mogrify without a background

I was following this example http://cubiq.org/create-fixed-size-thumbnails-with-imagemagick, and it's exactly what I want to do with the image, with the exception of having the background leftovers (i.e. the white borders). Is there a way to do this, and possibly crop the white background out? Is there another way to do this? The re-size needs to be proportional, so I don't just want to set a width re-size limit or height limit, but proportionally re-size the image.
The example you link to uses this command:
mogrify \
-resize 80x80 \
-background white \
-gravity center \
-extent 80x80 \
-format jpg \
-quality 75 \
-path thumbs \
*.jpg
First, mogrify is a bit dangerous. It manipulates your originals inline, and it overwrites the originals. If something goes wrong you have lost your originals, and are stuck with the wrong-gone results. In your case the -path thumbs however alleviates this danger, because makes sure the results will be written to sub directory thumbs
Another ImageMagick command, convert, can keep your originals and do the same manipulation as mogrify:
convert \
input.jpg \
-resize 80x80 \
-background white \
-gravity center \
-extent 80x80 \
-quality 75 \
thumbs/output.jpg
If want the same result, but just not the white canvas extensions (originally added to make the result a square 80x80 image), just leave away the -extent 80x80 parameter (the -background white and gravity center are superfluous too):
convert \
input.jpg \
-resize 80x80 \
-quality 75 \
thumbs/output.jpg
or
mogrify \
-resize 80x80 \
-format jpg \
-quality 75 \
-path thumbs \
*.jpg
I know this is an old thread, but by using the -write flag with the -set flag, one can write to files in the same directory without overwriting the original files:
mogrify -resize 80x80 \
-set filename:name "%t_small.%e" \
-write "%[filename:name]" \
*.jpg
As noted at http://imagemagick.org/script/escape.php, %t is the filename without extension and %e is the extension. So the output of image.jpg would be a thumbnail image_small.jpg.
This is the command I use each time I want to batch resized everything to 1920x and keep aspect ratio.
mogrify -path . -resize 1920x1920 -format "_resized.jpg" -quality 70 *.jpg

Resources