'ImageMagick: Cylinder keeping original on background
I'm trying to make a cylinder wrap via ImageMagick. It's working fine on creating the cylinder, but it's keeping the original image on back.
magick \
-verbose \
\( \
-size 2585x1181 \
xc:blue \
\( \
./images/test.png \
-geometry +820+0 \
\) \
-composite \
-geometry 730x390 \
-roll -230+0 \
-crop 270x408+0+0 \
+append \
\) \
-gravity south -background Transparent -splice 0x40 \
\( +clone -sparse-color barycentric '0,0 black 273,0 white' \) \
\( -clone 1 -function arcsin 0.5 \) \
\( -clone 1 -level 0%,100% \
-function polynomial -4,4,0 -gamma 2 \
+level 50%,0% \) \
-delete 1 \
-virtual-pixel Transparent \
-define compose:args=0x40 \
-compose Displace \
-composite \
./output/out.png
Thoughts?
Thanks
Solution 1:[1]
The issue is that in Imagemagick 7, whether a bug or a design feature, the distortion needs to be composed as one image with the X and Y distortions in the first two channels rather than as separate images.
In Imagemagick 6, this works
convert \
-verbose \
\( \
-size 2585x1181 \
xc:blue \
\( \
test.png \
-geometry +820+0 \
\) \
-composite \
-resize 730x390 \
-roll -230+0 \
-crop 270x408+0+0 +repage \
\) \
-gravity south -background none -splice 0x40 \
\( -clone 0 -set colorspace Gray -alpha off -sparse-color barycentric '0,0 black 270,0 white' \) \
\( -clone 1 -function arcsin 0.5 \) \
\( -clone 1 \
-function polynomial -4,4,0 -gamma 2 \
+level 50%,0% \) \
-delete 1 \
-background none -virtual-pixel none \
-define compose:args=20x40 \
-compose Displace \
-composite \
test_out1.png
But in Imagemagick 7, you have to do
magick \
\( \
-size 2585x1181 \
xc:blue \
\( \
test.png \
-geometry +820+0 \
\) \
-composite \
-geometry 730x390 \
-roll -230+0 \
-crop 270x408+0+0 \
\) \
-gravity south -background Transparent -splice 0x40 \
\( +clone \
-set colorspace Gray \
-alpha off \
-sparse-color barycentric '0,0 black 273,0 white' \
\( -clone 0 -function arcsin 0.5 \) \
\( -clone 0 \
-function polynomial -4,4,0 -gamma 2 \
+level 50%,0% \) \
\( +clone \) \
-delete 0 \
-combine \
-alpha off \
\) \
-virtual-pixel Transparent \
-define compose:args=20x40 \
-compose Displace \
-composite \
+channel \
test_out3.png
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | fmw42 |



