Cut the sides - or Zooming

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?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cut the sides - or Zooming

Post by fmw42 »

Where do I best add the command "-sharp 0x1.0" - to get the images a bit sharper?
Add it at the end of the first \( ... \) that follows the convert where the image itself is reduced and cropped, i.e.

convert \( $infile -define jpeg:size=${newsize}x${newsize} -thumbnail "${size}x${size}" -gravity center -crop ${xsize}x${ysize}+0+0 +repage -sharp 0x1.0 \) \ ....

or

convert \( $infile -define jpeg:size=${newsize}x${newsize} -thumbnail "${size}x${size}" -sharp 0x1.0 -gravity center -crop ${xsize}x${ysize}+0+0 +repage \) \
Albireo
Posts: 68
Joined: 2010-01-12T03:32:23-07:00
Authentication code: 8675309

Re: Cut the sides - or Zooming

Post by Albireo »

Thank you!

Nop! - "-sharp 0x1.0" :( doesn't work in any of the positions.
I got the following error:
convert: unrecognized option '-sharp' @ error/convert.c/convertImageCommand/2640.
What might have gone wrong - is it in my translation to windows?

My question about "NewSize" is still there - what does it mean?

Here is my translation into windows

Code: Select all

Echo off
cls

Set infile=d:\temp\pic\orig\hatching_orig.jpg
Rem Set infile=d:\temp\pic\orig\rot90.jpg
Set size=130

If not EXIST %infile% (
	Echo.
	Echo.
	Echo Missing filename: %infile%
	Echo.
	Echo.
	Goto End
	)

Set NewSize=convert xc: -format "%%[fx:%size%-3*%shadow%]" info:
Set ImgSize="%infile%" -define "jpeg:size=%size%x%size%" -thumbnail %size%x%size% -format %%wx%%h info:
convert %ImgSize% -format "Set ww=%%w\nSet hh=%%h" info:%TEMP%\getsize.bat
call %TEMP%\getsize.bat

if "%ww%" LEQ "%hh%" (
      Set xsize=120
      Set ysize=%hh%
      Set lsize=120
   ) else (
      Set xsize=%ww%
      Set ysize=120
      Set lsize=120
   )

call del /Q %Temp%\getsize.bat

Rem Set drawcmd=roundrectangle 1,1 119,97 15,15
convert %infile% -define "jpeg:size=%size%x%size%" -thumbnail %size%x%size% ^
         -gravity center -crop "%xsize%x%ysize%+0+0" +repage ^
         -format "roundrectangle 1,1 %%[fx:w-1],%%[fx:h-1] 15,15" info: > GetRectangle.txt

convert ( %infile% -define "jpeg:size=%newsize%x%newsize%" -thumbnail %size%x%size% ^
	-gravity center -crop %xsize%x%ysize%+0+0 +repage ) ^
	( +clone -threshold "100%%" -fill white -draw "@GetRectangle.txt" ) ^
	-alpha off -compose Copy_Opacity -composite ^
	( +clone -alpha transparent -background none -fill none ^
	-stroke black -strokewidth 1 -draw "@GetRectangle.txt" ) ^
	-compose Over -composite -background none ^
	-gravity center -extent %lsize%x%lsize% ^
	d:\temp\pic\hatching_rounded_border1.png

:End
Albireo
Posts: 68
Joined: 2010-01-12T03:32:23-07:00
Authentication code: 8675309

Re: Cut the sides - or Zooming

Post by Albireo »

Albireo wrote:Nop! - "-sharp 0x1.0" :( doesn't work in any of the positions.
I got the following error:
convert: unrecognized option '-sharp' @ error/convert.c/convertImageCommand/2640.
I found it :D the "name" is "-sharpen 0x1.0".

//Jan
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Cut the sides - or Zooming

Post by fmw42 »

newsize no longer exists in my last version of the script. it was replaced with size2 and other commands to separate it into ww and hh.

OK I see I left it in in one place by accident.

Try
infile="hatching_orig.jpg"
size=130
size2=`convert $infile -define jpeg:size=${size}x${size} -thumbnail "${size}x${size}" -format "%wx%h" info:`
ww=`echo $size2 | cut -dx -f1`
hh=`echo $size2 | cut -dx -f2`
if [ $ww -ge $hh ]; then
xsize=120
ysize=$hh
lsize=120
else
xsize=$ww
ysize=120
lsize=120
fi
drawcmd=`convert $infile -define jpeg:size=${size}x${size} -thumbnail "${size}x${size}" -gravity center -crop ${xsize}x${ysize}+0+0 +repage \
-format "roundrectangle 1,1 %[fx:w-1],%[fx:h-1] 15,15" info:`
convert \( $infile -define jpeg:size=${size}x${size} -thumbnail "${size}x${size}" -gravity center -crop ${xsize}x${ysize}+0+0 +repage \) \
\( +clone -threshold "100%" -fill white -draw "$drawcmd" \) \
-alpha off -compose Copy_Opacity -composite \
\( +clone -alpha transparent -background none \
-fill none -stroke black -strokewidth 1 -draw "$drawcmd" \) \
-compose Over -composite -background none -gravity center -extent ${lsize}x${lsize} \
hatching_rounded_border.png
Post Reply