According to the ImageMagick documentation, I would expect this:
convert fountain-pen1.jpg fountain-pen2.jpg handwriting.jpg -resize 400x400\> -set filename:f '%t_smol.%e' '%[filename:f]'
to result in fountain-pen1_smol.jpg fountain-pen2_smol.jpg handwriting_smol.jpg.
Instead, it only creates fountain-pen1_smol.jpg.
What am I doing wrong here?
I've also tried with just *.jpg which results in the same output.
convert -version
Version: ImageMagick 6.9.7-4 Q16 arm 20170114 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png tiff wmf x xml zlib
Mmm... sometimes you need to give ImageMagick a hint to create more output files than it is expecting to, using +adjoin:
convert fountain-pen1.jpg fountain-pen2.jpg handwriting.jpg -resize 400x400\> -set filename:f '%t_smol.%e' +adjoin '%[filename:f]'
It guesses this if you put a %02d or somesuch in the filename, but doesn't know that for your use case.
With ImageMagick you'll generally need to set that "filename:" variable right after reading in the images. Try this...
convert img1.jpg img2.jpg img3.jpg \
-set filename:f "%[t]_smol.%[e]" -resize 400x400\> "%[filename:f]"
That reads in the images, sets those output filenames right away, then performs the resizing operation, then writes the output files with the given names. Be aware that changing the order of the list or the number of images within the command can create unexpected results.
I've used this command successfully with IM 6.8.9 in bash. It works with 6.9 and 7.0 versions in Windows by changing the continued-line backslashes "\" to carets "^", and deleting the backslash and putting the resize "400x400>" inside double quotes.
Related
I'm using a recent version of ImageMagick on Windows 10 to resize and compress .tif files with mogrify *.tif -resize 20% -compress lzw. The input files are all the same dimensions and weigh a few hundred to a thousand KB, but the output files are all the same size, around 138 MB. This suggests to me that the mogrified files are being stored uncompressed. Using mogrify *.tif -compress zip leaves the files at their inflated size.
Why is the compression step failing?
Output of magick -version:
Version: ImageMagick 7.1.0-35 Q16-HDRI x64 ff6dbbb:20220516 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenCL OpenMP(2.0)
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg jxl lcms lqr lzma openexr pangocairo png ps raqm raw rsvg tiff webp xml zip zlib
Compiler: Visual Studio 2022 (193231328)
The sequence of commands is important: success was obtained with mogrify -resize 20% -compress lzw *.tif.
I have a simple ImageMagick command that uses -contrast which is well-documented here: https://imagemagick.org/script/command-line-options.php#contrast
My command:
magick in.jpg -enhance -contrast -background white -quality 100 -resize 200x200^ -gravity center -extent 200x200 out.jpg
But I'm getting this error: magick: option has been replaced '-contrast', use "-level" at CLI arg 3 # warning/operation.c/CLISimpleOperatorImage/2078.
I'm using ImageMagick 7.0.9-7 Q16 x86_64 2019-12-02.
Features: Cipher DPC HDRI Modules OpenMP(3.1)
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc heic jbig jng jp2 jpeg lcms ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zlib
So... why is it complaining about the -contrast option? It looks like -contrast is still there, and I don't see how -level is supposed to replace it. There's nothing I can find about -contrast being replaced/removed. It's very strange.
** UPDATE - even I can see right here in the code where that error message is generated. However, I can't see why it's doing that, and as I said, can't find anything in any documentation that implies -contrast should not be used.
I have lot of images and not i want to split them w.r.t aspect ratio.
What is presently working is
convert -crop 2:1 input.png cropped_%d.png
The above command split the image. Assuming i have 900px x 2000px then it creates 5 images.
But now the problem is i want to keep some overlap
I tried
convert -crop 2:1+0+40 input.png cropped_%d.png
Its only giving one image.
I tried
convert -crop 1x4+0+40# Settings_commit1.png cropped_%d.png
This works well. But here i have to mention 1x4 (grid). But I want to do it by aspect ratio
I did the following way
$ convert --version
Version: ImageMagick 7.0.8-35 Q16 x86_64 2019-03-25 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenCL OpenMP
Delegates (built-in): bzlib cairo fontconfig freetype gslib heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raw rsvg tiff webp wmf x xml zlib
The two commands split the image:
Based on aspect ratio split the image file (but overlap does not work 2:1+0+40)
convert -crop 2:1 input.png cropped_%d.png
Based on grid split the image file and overlap works (+0+40)
convert -crop 1x4+0+40# Settings_commit1.png cropped_%d.png (with 40px vertical overlap)
Logic is we get the number of split images from aspect ratio and then use it in grid
This is the scrip which worked
filename="someimage.png";
# just creating a dir and empty it
mkdir ~/croped
rm -rf ~/croped/*
# split the image base on aspect ratio and save them in croped folder
convert -crop 903:600 ${filename} ~/croped/crop_aspect_%d.png;
# count the number of files in the croped folder
number_files=`ls -l ~/croped | grep -E "crop_aspect_*" | wc -l`
# based on this number apply the grid
convert -crop 1x${number_files}+0+8# ${filename} ~/croped/crop_grid_%d.png
So I am trying to display an Arabic word using ImageMagick.
This is my code:
convert -size 1144x800 -background transparent -font "arabic_reg.ttf" -encoding Unicode label:#arabic.utf8 "oops.png"
#arabic.utf8 is saved in utf-8 and arabic_reg.ttf is an arabic font.
This is the result
letters are detached and inverted
adding -direction right-to-left doesn't seem to help also.
I am running ImageMagick 6.9.6-2 on mac.
Version: ImageMagick 6.9.6-2 Q16 x86_64 2016-10-20
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
Features: Cipher DPC Modules
Delegates (built-in): bzlib djvu fftw fontconfig freetype gslib jbig jng jp2 jpeg lcms ltdl lzma openexr png ps tiff webp x xml zlib
Any idea how to fix this?
Thanks
Ran into the same problem, you gotta use pango and install the fonts in your system :)
I'm trying to montage some semi-transparent icons into one image using imagemagicks montage tool.
Unfortunately, after every operation with alpha a bit of black is showing everywhere on anti-aliased edges.
For example, these two icons:
and
After issuing
montage 1.png 2.png -background none montage.png
Result in:
I've tried numerous combinations of alpha, background and changing option order and haven't found a way to prevent this. Any idea?
My system is windows 8.1+cygwin, montage version is:
$ montage -version
Version: ImageMagick 6.9.1-3 Q16 x86_64 2015-07-01
http://www.imagemagick.org Copyright: Copyright (C) 1999-2015
ImageMagick Studio LLC License:
http://www.imagemagick.org/script/license.php Features: DPC OpenMP
Delegates (built-in): autotrace bzlib cairo fftw fontconfig freetype
fpx gslib jbig jng jpeg lcms lzma pangocairo png ps rsvg tiff webp x xml zlib
This looks like a version-specific bug, as the given command works fine on ImageMagick 6.9.1-10 and also using:
convert 1.png 2.png +append 3.png