Convert
<yambe:breadcrumb>Image processing tools</yambe:breadcrumb>
convert
We can use convert to convert from one image format to another. For example to convert 'test.png' to 'test.jpg' we can use:
convert test.png test.jpg
Convert command also supports many options. One can use 'convert -help' to see brief description and supported options. For details we need to use ImageMagick package documentation.
Creating ebook from scanned files
We can create 'pdf' ebook from scanned files with the help of convert which is part of ImageMagick package using following steps:
- First all the pages of book can be scanned in 'png' format with image names corresponding to page number like 'page001.png', 'page002.png' and so on.
- Edit all 'png' pages and remove the extra part of image which is not useful
- Use below command to create pdf which has pages in right order as per image file name
- convert *.png ebook.pdf
- Note: Use at least 300 dpi during scanning to create a good usable ebook.
Converting train tickets to pdf format
Do not use this technique as tickets created do not have good resolution and are not useful
Using print to file and then pdf format from IRCTC using Mozilla Firefox in Linux leads to corrupted pdf which will print all black color instead of ticket details. One can verify whether pdf is printable or not by opening it in kpdf and using print preview.
To make proper pdf file:
- Use 'Print to file' option and choose postscript.
- Save file as 'ticket.ps'.
- Now use command 'convert ticket.ps ticket.bmp' to convert ticket to bitmap format. This will create two bmp files 'ticket-00.bmp' and 'ticket-1.bmp' containg first and second page of ticket.
- Delete file 'ticket-1.bmp'.
- Open file 'ticket-0.bmp' with Kolourpaint or GIMP and remove the advertizement. Save the file as 'ticket-0.bmp'. Note that we are using bmp format and not png/jpg etc. and png/jpg are not lossless formats.
- Now use 'convert ticket-0.bmp ticket.pdf' to get proper pdf file without ads which can be printed without any problem.
Resizing image
To resize an image using convert use:
convert src.jpg -resize 10x10 dst.jpg
where 10x10 is the desired size of destination image. The resulting image is automatically centered to maintain aspect ratio.
Cropping image
To crop an image using convert use:
convert src.jpg -crop 22x38+10+12 dst.jpg
Here, 22x38 is the size of the resulting image after crop. +10 is the X offset even - can be used to indicate coordinates from other direction. Similarly +12 is the Y offset. Here also instead of +, - can be used to indicate counting in opposite direction.
<yambe:breadcrumb>Image processing tools</yambe:breadcrumb>