Wraping around a Cylinder in Windows
Wraping around a Cylinder in Windows
Hello all. I need to wrap an image (roughly 8" x 4") around a image of a mug. Of course, Fred's Cylinderize function would work great; however, I don't work with UNIX/MAC/LINUX, and cylinderize is not a valid argument in a standard IM deployment. I am leveraging IM in Windows 7 through MSAccess using VBA. A typical command looks like this:
objMi.Convert myoldimage, "-background", "white", "-flatten", mynewimage
My problem is that I cannot use Fred's scripts because I cannot install all of the required components into my work's Window's system, yet the "Overlay Example 2" is exactly what I need.
Is there another, perhaps less efficient way to wrap the image using traditional IM commands? Even if it's many individual steps?
Thanks for any insight.
Cheers.
objMi.Convert myoldimage, "-background", "white", "-flatten", mynewimage
My problem is that I cannot use Fred's scripts because I cannot install all of the required components into my work's Window's system, yet the "Overlay Example 2" is exactly what I need.
Is there another, perhaps less efficient way to wrap the image using traditional IM commands? Even if it's many individual steps?
Thanks for any insight.
Cheers.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Wraping around a Cylinder in Windows
You could install Cygwin and then run my scripts. Alternately, see http://www.imagemagick.org/Usage/mappin ... e_cylinder
Re: Wraping around a Cylinder in Windows
I am unable to install the Cygwin package, unfortunately (not allowed). In the meantime, though, if I follow that example script, I'm still having a little problem encoding it with VB.
convert rose: -background black -gravity south -splice 0x8 \
\( +clone -sparse-color barycentric '0,0 black 69,0 white' \) \
\( +clone -function arcsin 0.5 \) \
\( -clone 1 -level 25%,75% \
-function polynomial -4,4,0 -gamma 2 \
+level 50%,0 \) \
-delete 1 -swap 0,1 miff:- |\
composite - -virtual-pixel black -displace 17x7 rose_cylinder.png
how does that look if it's a single command line? (actually two lines)
I didn't think some of those commands could be combined, and when I try to run them line by line, it's not working.
It's a shame I cannot just use your function, but c'est la vie. I need to build it the hard way and it's not built into IM.
Do you have any idea if the distort barrel command could get me close. It's seemingly way easier to work with.
convert rose: -background black -gravity south -splice 0x8 \
\( +clone -sparse-color barycentric '0,0 black 69,0 white' \) \
\( +clone -function arcsin 0.5 \) \
\( -clone 1 -level 25%,75% \
-function polynomial -4,4,0 -gamma 2 \
+level 50%,0 \) \
-delete 1 -swap 0,1 miff:- |\
composite - -virtual-pixel black -displace 17x7 rose_cylinder.png
how does that look if it's a single command line? (actually two lines)
Code: Select all
convert rose: -background black -gravity south -splice 0x8 +clone -sparse-color barycentric '0,0 black 69,0 white' +clone -function arcsin 0.5 -clone 1 -level 25%,75% -function polynomial -4,4,0 -gamma 2 +level 50%,0 -delete 1 -swap 0,1 miff
composite - -virtual-pixel black -displace 17x7 rose_cylinder.png
It's a shame I cannot just use your function, but c'est la vie. I need to build it the hard way and it's not built into IM.
Do you have any idea if the distort barrel command could get me close. It's seemingly way easier to work with.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Wraping around a Cylinder in Windows
clones must be enclosed by parens. Windows syntax is different. Remove the \. See http://www.imagemagick.org/Usage/windows/
convert rose: -background black -gravity south -splice 0x8 ^
( +clone -sparse-color barycentric '0,0 black 69,0 white' ) ^
( +clone -function arcsin 0.5 ) ^
( -clone 1 -level 25%,75% ^
-function polynomial -4,4,0 -gamma 2 ^
+level 50%,0 ) ^
-delete 1 -swap 0,1 miff:- |^
composite - -virtual-pixel black -displace 17x7 rose_cylinder.png
If you want to make it two commands, remove the ^ from the first part and put it all on one line and remove the pipe and save the intermediate miff: as tmp.miff to disk, then remove later.
If you want it all as one command, use convert .... -composite rather than composite and remove the -swap 0,1
convert rose: -background black -gravity south -splice 0x8 ^
( +clone -sparse-color barycentric '0,0 black 69,0 white' ) ^
( +clone -function arcsin 0.5 ) ^
( -clone 1 -level 25%,75% ^
-function polynomial -4,4,0 -gamma 2 ^
+level 50%,0 ) ^
-delete 1 ^
-virtual-pixel black -define compose:args=17x7 -compose displace -composite rose_cylinder.png
This works for me in unix equivalent syntax on IM 6.8.8.10 Q16 Mac OSX
You do not say what version of IM you are using. That is always a good idea, since some IM commands are not available in older versions.
convert rose: -background black -gravity south -splice 0x8 ^
( +clone -sparse-color barycentric '0,0 black 69,0 white' ) ^
( +clone -function arcsin 0.5 ) ^
( -clone 1 -level 25%,75% ^
-function polynomial -4,4,0 -gamma 2 ^
+level 50%,0 ) ^
-delete 1 -swap 0,1 miff:- |^
composite - -virtual-pixel black -displace 17x7 rose_cylinder.png
If you want to make it two commands, remove the ^ from the first part and put it all on one line and remove the pipe and save the intermediate miff: as tmp.miff to disk, then remove later.
If you want it all as one command, use convert .... -composite rather than composite and remove the -swap 0,1
convert rose: -background black -gravity south -splice 0x8 ^
( +clone -sparse-color barycentric '0,0 black 69,0 white' ) ^
( +clone -function arcsin 0.5 ) ^
( -clone 1 -level 25%,75% ^
-function polynomial -4,4,0 -gamma 2 ^
+level 50%,0 ) ^
-delete 1 ^
-virtual-pixel black -define compose:args=17x7 -compose displace -composite rose_cylinder.png
This works for me in unix equivalent syntax on IM 6.8.8.10 Q16 Mac OSX
You do not say what version of IM you are using. That is always a good idea, since some IM commands are not available in older versions.
Re: Wraping around a Cylinder in Windows
I'm using 6.8.8-10 Q8 64. I couldn't get this to work in the Windows cmd console. I'm going to have to find a different path...maybe a crop/wave or some other mix. It's kicking out a ton of errors and I've already spent 2 full days trying to get it to work. Oh well. Thanks, though!
convert mug.png -background black -gravity south -splice 0x8 (+clone -sparse-color barycentric '0,0 black 69,0 white') (+clone -function arcsin 0.5) (-clone 1 -level 25%,75% -function polynomial -4,4,0 gamma 2 +level 50%,0) -delete 1 -virtual-pixel black -define compose:args=17x7 -compose displace -composite mug_cylinder.png
If I remove the parens, the console crashes. The resulting image is all messed up (garmentdeli.com/mug_cylinder.png). Original image: garmentdeli.com/mug.png.
convert.exe: unable to open image `(+clone': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `(+clone' @ error/constitute.c/ReadImage/501.
convert.exe: iCCP: Not recognizing known sRGB profile that has been edited `mug.png' @ warning/png.c/MagickPNGWarningHandler/1832.
convert.exe: invalid argument for option `sparse-color': Invalid number of Arguments @ error/mogrify.c/SparseColorOption/526.
convert.exe: unable to open image `black': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `black' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `69,0': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `69,0' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `white')': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `white')' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `(+clone': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `(+clone' @ error/constitute.c/ReadImage/501.
convert.exe: iCCP: Not recognizing known sRGB profile that has been edited `mug.png' @ warning/png.c/MagickPNGWarningHandler/1832.
convert.exe: unable to open image `(-clone': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `(-clone' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `1': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `1' @ error/constitute.c/ReadImage/501.
convert mug.png -background black -gravity south -splice 0x8 (+clone -sparse-color barycentric '0,0 black 69,0 white') (+clone -function arcsin 0.5) (-clone 1 -level 25%,75% -function polynomial -4,4,0 gamma 2 +level 50%,0) -delete 1 -virtual-pixel black -define compose:args=17x7 -compose displace -composite mug_cylinder.png
If I remove the parens, the console crashes. The resulting image is all messed up (garmentdeli.com/mug_cylinder.png). Original image: garmentdeli.com/mug.png.
convert.exe: unable to open image `(+clone': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `(+clone' @ error/constitute.c/ReadImage/501.
convert.exe: iCCP: Not recognizing known sRGB profile that has been edited `mug.png' @ warning/png.c/MagickPNGWarningHandler/1832.
convert.exe: invalid argument for option `sparse-color': Invalid number of Arguments @ error/mogrify.c/SparseColorOption/526.
convert.exe: unable to open image `black': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `black' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `69,0': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `69,0' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `white')': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `white')' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `(+clone': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `(+clone' @ error/constitute.c/ReadImage/501.
convert.exe: iCCP: Not recognizing known sRGB profile that has been edited `mug.png' @ warning/png.c/MagickPNGWarningHandler/1832.
convert.exe: unable to open image `(-clone': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `(-clone' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `1': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `1' @ error/constitute.c/ReadImage/501.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Wraping around a Cylinder in Windows
Parens must have spaced between them and what is insideconvert mug.png -background black -gravity south -splice 0x8 (+clone -sparse-color barycentric '0,0 black 69,0 white') (+clone -function arcsin 0.5) (-clone 1 -level 25%,75% -function polynomial -4,4,0 gamma 2 +level 50%,0) -delete 1 -virtual-pixel black -define compose:args=17x7 -compose displace -composite mug_cylinder.png
Code: Select all
convert mug.png -background black -gravity south -splice 0x8 ( +clone -sparse-color barycentric '0,0 black 69,0 white' ) ( +clone -function arcsin 0.5 ) ( -clone 1 -level 25%,75% -function polynomial -4,4,0 gamma 2 +level 50%,0 ) -delete 1 -virtual-pixel black -define compose:args=17x7 -compose displace -composite mug_cylinder.png
Re: Wraping around a Cylinder in Windows
Thanks for the adjustment, but it's just not working. I copied & pasted your code exactly and it's still throwing all kinds of errors. I think I need to find another path unless you see something obvious. Otherwise, I truly appreciate your input, but I don't want you to waste your time on it.
convert.exe: invalid argument for option `sparse-color': Invalid number of Arguments @ error/mogrify.c/SparseColorOption/526.
convert.exe: unable to open image `black': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `black' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `69,0': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `69,0' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `white'': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `white'' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `gamma': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `gamma' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `2': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `2' @ error/constitute.c/ReadImage/501.
convert.exe: invalid argument for option `sparse-color': Invalid number of Arguments @ error/mogrify.c/SparseColorOption/526.
convert.exe: unable to open image `black': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `black' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `69,0': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `69,0' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `white'': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `white'' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `gamma': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `gamma' @ error/constitute.c/ReadImage/501.
convert.exe: unable to open image `2': No such file or directory @ error/blob.c/OpenBlob/2645.
convert.exe: no decode delegate for this image format `2' @ error/constitute.c/ReadImage/501.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Wraping around a Cylinder in Windows
Code: Select all
-sparse-color barycentric '0,0 black 69,0 white'
Code: Select all
-sparse-color barycentric "0,0 black 69,0 white"
Code: Select all
-sparse-color barycentric 0,0,black,69,0,white
snibgo's IM pages: im.snibgo.com
Re: Wraping around a Cylinder in Windows
Well, the good thing is that thanks to snibgo, I got some of this working in Windows. THANK YOU. However, what I'm trying to do is recreate what snibgo does here viewtopic.php?f=1&t=18497 THIS image:
I have looked at the thread above and this one http://www.imagemagick.org/Usage/mappin ... e_cylinder but I have not been able to recreate the same curvature after manipulating every variable.
Instead, I get this...
or with a little tweaking:
This is my base, single line code that I have tweaking to no avail. I have tweaked the polynomial, the gamma, the args, but to no avail.
How, exactly, does snibgo get that centered curvature? I'm using the exact same trimmed base image and seemingly the same variables:
I have looked at the thread above and this one http://www.imagemagick.org/Usage/mappin ... e_cylinder but I have not been able to recreate the same curvature after manipulating every variable.
Instead, I get this...
or with a little tweaking:
This is my base, single line code that I have tweaking to no avail. I have tweaked the polynomial, the gamma, the args, but to no avail.
Code: Select all
convert orig3.png -background white -gravity south -splice 0x50 -set colorspace RGB ( +clone -sparse-color barycentric "0,0 black 347,0 white" ) ( +clone -function arcsin 0.5 ) ( -clone 1 -level 25%,75% -function polynomial-4,4,0, -gamma 2 +level 50%,0 ) -delete 1 -virtual-pixel white -compose displace -define compose:args=86.75x49 -composite mug_cylinder.png
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Wraping around a Cylinder in Windows
A detailed dissection of the algorithm is giving in IM Examples
http://www.imagemagick.org/Usage/mappin ... e_cylinder
http://www.imagemagick.org/Usage/mappin ... e_cylinder
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Wraping around a Cylinder in Windows
I've registered myself just to say THANK YOU for this:
Thanks again.
You made my day, really. I was trying to use the sample algorithm an ImageMagick module for Drupal (IM RAW) and I was having problems with the miff:- command.fmw42 wrote:If you want it all as one command, use convert .... -composite rather than composite and remove the -swap 0,1
convert rose: -background black -gravity south -splice 0x8 ^
( +clone -sparse-color barycentric '0,0 black 69,0 white' ) ^
( +clone -function arcsin 0.5 ) ^
( -clone 1 -level 25%,75% ^
-function polynomial -4,4,0 -gamma 2 ^
+level 50%,0 ) ^
-delete 1 ^
-virtual-pixel black -define compose:args=17x7 -compose displace -composite rose_cylinder.png
Thanks again.