Extend png canvas size by a few pixels?

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, helmut, xnview

Posts: 1
Joined: Wed Dec 26, 2018 12:59 pm

Extend png canvas size by a few pixels?

Post by scriptor »

I've got a couple of png files that need to be altered in order to OCR them with Tesseract.
The dimensions are 100 x 13 pixels and I need to add 3 pixels to the bottom side of the images, resulting in 100 x 16 pixels.
(To enhance the contrast I add the -binary parameter as well.)

So basically what I'm looking for is the equivalent of the XnView command
Canvas resize: Add 3 dots/pixels from Top-Center of background/custom colour (#f6f6f6)
Is this feasible with NConvert?
Posts: 4022
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Extend png canvas size by a few pixels?

Post by cday »

You have the NConvert help file (-help) have you?

I would think the following option should work, if you try it:

Code: Select all

-canvas w h pos   : Resize canvas
              w h can be percent (ex: -canvas 100% 200%)
              or #x #y for offset
              pos top-left, top-center, top-right
                  center-left, center, center-right
                  bottom-left, bottom-center, bottom-right

You could check if setting w and h to the desired canvas dimensions works, and if not try the offset option, I'm not sure about that...

But will Tesseract produce useful output from such small pixel dimensions?