Question on Convert + Montage

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Question on Convert + Montage

Post by henrywho »

I tried to create a thumbnail image:

Code: Select all

set DOUSM=-unsharp 0x0.75+0.75+0.008
set RESIZE=83x61! -alpha off +repage

convert wizard: -set colorspace sRGB -colorspace RGB ^
 ^( -clone 0 -filter Point -resize %RESIZE% -set caption "Point" ^) ^
 ^( -clone 0 -filter Point -resize %RESIZE% -set caption "Point" ^) ^
 ^( -clone 0 -filter Point -resize %RESIZE% -set caption "Point" ^) ^
 ^( -clone 0 -filter Point -resize %RESIZE% -set caption "Point" ^) ^
 ^( -clone 0 -filter Point -resize %RESIZE% -set caption "Point" ^) ^
 ^( -clone 0 -filter Point -resize %RESIZE% -set caption "Point" ^) ^
 ^( -clone 0 -filter Point -resize %RESIZE% -set caption "Point" ^) ^
 ^( -clone 0 -filter Point -resize %RESIZE% -set caption "Point" ^) ^
 ^( -clone 0 -define filter:window=Quadratic -define filter:lobes=3 -distort resize %RESIZE% -set caption "E/QuadraticJinc" ^) ^
 ^( -clone 0 -filter Point -resize %RESIZE% -set caption "Point" ^) ^
 ^( -clone 0 -filter Point -resize %RESIZE% -set caption "Point" ^) ^
 ^( -clone 0 -filter Point -resize %RESIZE% -set caption "Point" ^) ^
 ^( -clone 0 -filter Point -resize %RESIZE% -set caption "Point" ^) ^
 ^( -clone 0 -define filter:window=Quadratic -define filter:lobes=3 -distort resize %RESIZE% %DOUSM% -set caption "E/QuadraticJinc/U" ^) ^
 ^( -clone 0 -filter Point -resize %RESIZE% -set caption "Point" ^) ^
 -delete 0 -colorspace sRGB temp.miff
 
montage -label "%[caption]" temp.miff -geometry "120x75^>+2+2" -tile 5x ^
 -background lightgrey -fill black -title "Downsampling Test" ^
 -depth 8 -quality 95% downsamplingtest.png
But the result is obviously wrong:
Image

What's wrong with the command lines I used?
henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: Question on Convert + Montage

Post by henrywho »

The result is the same if I use "temp.mpc" instead of "temp.miff".
henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: Question on Convert + Montage

Post by henrywho »

In unix syntax (cygwin or msys):

Code: Select all

export DOUSM="-unsharp 0x0.75+0.75+0.008"
export RESIZE="83x61! -alpha off +repage"

./convert wizard.png -set colorspace sRGB -colorspace RGB \
 \( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
 \( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
 \( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
 \( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
 \( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
 \( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
 \( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
 \( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
 \( -clone 0 -define filter:window=Quadratic -define filter:lobes=3 -distort resize ${RESIZE} -set caption "E/QuadraticJinc" \) \
 \( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
 \( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
 \( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
 \( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
 \( -clone 0 -define filter:window=Quadratic -define filter:lobes=3 -distort resize ${RESIZE} ${DOUSM} -set caption "E/QuadraticJinc/U" \) \
 \( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
 -delete 0 -colorspace sRGB miff:- | ./montage -label "%[caption]" - -geometry "120x75>+2+2" -tile 5x \
 -background lightgrey -fill black -title "Downsampling Test" \
 -depth 8 -quality 95% downsamplingtest_miff.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Question on Convert + Montage

Post by fmw42 »

Hello henrywho,

What is the issue at hand?

Each of your images is the same except for two. Why not just create 3 with the appropriate label and -clone or -duplicate the others to repeat the point version, then pipe that to montange. You might also try adding -respect-parenthesis at the beginning of your convert command before the sequence of parentheses. see
http://www.imagemagick.org/Usage/basics/#controls But without understanding the problem this may just be a guess.

This works faster than your version and does show different images that are smoother for the two non-point images due to the -respect parenthesis. (I tried it with and without and there is a clear difference). My guess is that -filter point is persisting without it. So I assume that was the issue at hand? I presume this is a test for when you want each image to be a different filter. So if that is the case, then the clone parts are only relevant to this example.

DOUSM="-unsharp 0x0.75+0.75+0.008"
RESIZE="83x61! -alpha off +repage"
convert wizard: -set colorspace sRGB -colorspace RGB -respect-parenthesis \
\( -clone 0 -filter Point -resize ${RESIZE} -set caption "Point" \) \
\( -clone 1 \) \
\( -clone 1 \) \
\( -clone 1 \) \
\( -clone 1 \) \
\( -clone 1 \) \
\( -clone 1 \) \
\( -clone 1 \) \
\( -clone 0 -define filter:window=Quadratic -define filter:lobes=3 -distort resize ${RESIZE} -set caption "E/QuadraticJinc" \) \
\( -clone 1 \) \
\( -clone 1 \) \
\( -clone 1 \) \
\( -clone 1 \) \
\( -clone 0 -define filter:window=Quadratic -define filter:lobes=3 -distort resize ${RESIZE} ${DOUSM} -set caption "E/QuadraticJinc/U" \) \
\( -clone 1 \) \
-delete 0 -colorspace sRGB miff:- | montage -label "%[caption]" - -geometry "120x75>+2+2" -tile 5x \
-background lightgrey -fill black -title "Downsampling Test" \
-depth 8 -quality 95 2downsamplingtest.png


Also -quality is not percent, that is no % symbol is needed. For jpg it is like percent without the % as it is in the range 0 to 100. But for png, it is measured differenly, though I am no expert on that. So see
http://www.imagemagick.org/script/comma ... hp#quality
http://www.imagemagick.org/Usage/formats/#png_write
henrywho
Posts: 188
Joined: 2011-08-17T06:46:40-07:00
Authentication code: 8675308

Re: Question on Convert + Montage

Post by henrywho »

Yeah! "-respect-parenthesis" does the magic!

But why doesn't NicolasRobidoux need this parameter when he produces his samples?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Question on Convert + Montage

Post by fmw42 »

henrywho wrote:Yeah! "-respect-parenthesis" does the magic!

But why doesn't NicolasRobidoux need this parameter when he produces his samples?
I do not know how he does it. As he is using IM 7 magick command rather than IM 6 convert, then perhaps there is a difference or fix in IM 7.
Post Reply