I'm wanting to resize some seamlessly tileable images in such a way that the results are also seamlessly tileable. The resize filter therefore needs to sample pixels beyond the image border in a wrapped/repeated/tiled fashion in order to prevent artifacts.
I imagine a montage -> resize -> crop sequence will do what I want, but is there any more direct/simple/efficient method?
Most direct way to resize with tiled/wrapped edges?
-
- Posts: 12
- Joined: 2014-01-23T17:11:13-07:00
- Authentication code: 6789
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Most direct way to resize with tiled/wrapped edges?
This sounds like "-virtual-pixel tile", which is the default. See http://www.imagemagick.org/script/comma ... #clip-path
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Most direct way to resize with tiled/wrapped edges?
I was under the impression that the default for -virtual-pixel is edge. At least that is what is says below the table at http://www.imagemagick.org/script/comma ... tual-pixel. So there is some confusion here because the table says tile is the default.
If you do
convert rose: -distort srt 45 show:
convert rose: -virtual-pixel tile -distort srt 45 show:
convert rose: -virtual-pixel edge -distort srt 45 show:
The first and third match, so it would appear that edge is the default.
I am not sure what was meant by (default) next to tile. Perhaps it was a typo.
If you do
convert rose: -distort srt 45 show:
convert rose: -virtual-pixel tile -distort srt 45 show:
convert rose: -virtual-pixel edge -distort srt 45 show:
The first and third match, so it would appear that edge is the default.
I am not sure what was meant by (default) next to tile. Perhaps it was a typo.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Most direct way to resize with tiled/wrapped edges?
PS I do not see what -virtual-pixel tile will have to do with resize.
I think you need to use the viewport setting with -distort srt to get what you want by setting the viewport size (and offset) to be bigger than the srt scaled sized
See
http://www.imagemagick.org/Usage/distor ... t_viewport
http://www.imagemagick.org/Usage/distorts/#srt
Perhaps you can show us what exactly you are trying to do?
I think you need to use the viewport setting with -distort srt to get what you want by setting the viewport size (and offset) to be bigger than the srt scaled sized
See
http://www.imagemagick.org/Usage/distor ... t_viewport
http://www.imagemagick.org/Usage/distorts/#srt
Perhaps you can show us what exactly you are trying to do?
-
- Posts: 12
- Joined: 2014-01-23T17:11:13-07:00
- Authentication code: 6789
Re: Most direct way to resize with tiled/wrapped edges?
Thanks for the help, guys. -virtual-pixel tile sounds like what I want, but it doesn't seem to be working with resize. It might work with distort, but at the moment I'm specifically hoping to work with an orthogonal truncated sinc filter.
To give an example of what I want, consider this source image:
convert Source.png -virtual-pixel tile -filter Sinc -resize 16 Bad_Borders_Resize.png results in this, because the downsampling filter is either omitting samples outside the image or replacing them with the edge pixel (probably the former?):
Blown up with nearest neighbor:
I would like something more like this, which is the result of tiling the image 3x3 in Gimp, resizing to 48 in ImageMagick, and cropping to the middle tile:
i.e.:
To give an example of what I want, consider this source image:
convert Source.png -virtual-pixel tile -filter Sinc -resize 16 Bad_Borders_Resize.png results in this, because the downsampling filter is either omitting samples outside the image or replacing them with the edge pixel (probably the former?):
Blown up with nearest neighbor:
I would like something more like this, which is the result of tiling the image 3x3 in Gimp, resizing to 48 in ImageMagick, and cropping to the middle tile:
i.e.:
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Most direct way to resize with tiled/wrapped edges?
try this (unix syntax on relatively current IM) (if older IM you need to use clones rather than -duplicate)
convert Source.png -duplicate 2 +append -duplicate 2 -append \
-virtual-pixel tile -filter Sinc -resize 48x48 \
-gravity center -crop 33.33x33.33+0+0% +repage \
-filter point -resize 128x128 result.png
or
convert Source.png -duplicate 2 +append -duplicate 2 -append \
-virtual-pixel tile -filter Sinc -resize 48x48 \
-gravity center -crop 16x16+0+0 +repage \
-filter point -resize 128x128 result.png
Leave off the last line if you do not want the final resize for viewing.
convert Source.png -duplicate 2 +append -duplicate 2 -append \
-virtual-pixel tile -filter Sinc -resize 48x48 \
-gravity center -crop 33.33x33.33+0+0% +repage \
-filter point -resize 128x128 result.png
or
convert Source.png -duplicate 2 +append -duplicate 2 -append \
-virtual-pixel tile -filter Sinc -resize 48x48 \
-gravity center -crop 16x16+0+0 +repage \
-filter point -resize 128x128 result.png
Leave off the last line if you do not want the final resize for viewing.
-
- Posts: 12
- Joined: 2014-01-23T17:11:13-07:00
- Authentication code: 6789
Re: Most direct way to resize with tiled/wrapped edges?
Oh, excellent! That's a good bit more convenient than the two-pass montage -> resize + crop solution. Thanks!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Most direct way to resize with tiled/wrapped edges?
Not much different from montage. With montage, you could tile the image and pipe the result to convert to do the resize.CranberryBBQ wrote:Oh, excellent! That's a good bit more convenient than the two-pass montage -> resize + crop solution. Thanks!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Most direct way to resize with tiled/wrapped edges?
Here is another method, but you need to know the input size times 3
convert -size 540x540 tile:Source.png \
-virtual-pixel tile -filter Sinc -resize 48x48 \
-gravity center -crop 16x16+0+0 +repage \
-filter point -resize 128x128 result.png
see
http://www.imagemagick.org/Usage/canvas/#tile
convert -size 540x540 tile:Source.png \
-virtual-pixel tile -filter Sinc -resize 48x48 \
-gravity center -crop 16x16+0+0 +repage \
-filter point -resize 128x128 result.png
see
http://www.imagemagick.org/Usage/canvas/#tile