Resizing to 100% x 1pixel

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
jaffamuffin
Posts: 59
Joined: 2009-01-30T03:46:08-07:00

Resizing to 100% x 1pixel

Post by jaffamuffin »

Hi

How can I take a set of images, which will be roughly 2300x3300 pixels and resize this to 2300x1, or in the case of a 2345x3230 sized image, resize this to 2345x1.

Essentially I want 100% image width, but 1px height. I can't seem to get IM to do this. The only way I can make it do it is using ! but I need to know the original size of the image.

If I use 100% x 1 It doesn't resize to 1 pixel.


Any ideas?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Resizing to 100% x 1pixel

Post by snibgo »

Inelegant solution (Ubuntu):

Code: Select all

convert input.png -resize `convert input.png -format %[fx:w] info:`x1! output.png
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Resizing to 100% x 1pixel

Post by fmw42 »

100%x1 is the same as 100%x1% or 100x1%. If IM sees a %, it applies it to both.

try

convert image -resize "100x0%!" result

0% means 0 size, but IM will make it 1 pixel (from my testing).
jaffamuffin
Posts: 59
Joined: 2009-01-30T03:46:08-07:00

Re: Resizing to 100% x 1pixel

Post by jaffamuffin »

convert image -resize "100x0%!" result

Ahh yes thanks that does work. I actually tried using 0 as a token but kept getting image errors.

my command is convert left.tif -resize "100x0%!" +repage -threshold 210 c:\out2.tif

I'll output this to text locate the first block of black on the right of the page which should be the spine of the scanned book. The perform a page size crop to extract only the page sized data.

Similar in a way to my set of scripts here viewtopic.php?f=1&t=14443
Post Reply