Graphics and PDF Editing Cheat Sheet
Sep. 22nd, 2022 09:32 amThis is a list of tips for converting and working with and printing documents and photos.
I'm out of black ink but still have color. I need something printed now and don't have time to buy another ink cartridge.
This trick converts the black (rgb 0x000000) colors in a graphic to blue (rgb 0x0000FF), so I can print with the color cartridge:
convert original.png -fuzz 25% -fill "rgb(0,0,255)" -opaque "rgb(0,0,0)" new.png
I need to edit a PDF file and send it to someone, but I don't want to print it out, make the changes to the printed copy and scan it back in. I'd like a paperless way to make my changes.
If the document is in PDF format, use Inkscape (or InkscapePortable). Open the PDF file. Be sure to select Poppler/Cairo import under Import Settings. Then, you can export it as a graphic file a page at a time.
You can edit a page in Inkscape itself or output it as a graphic file and edit it in another graphics editor. Export each page you need as a separate graphic using Inkscape. When you're ready to combine them and create a new PDF with the contents and your changes, use wkhtmltopdf.
Create a simple html file similar to this:
<html>
<body>
<img style="height: 11in" src="graphic000.jpg">
<div style="page-break-after: always;"><span style="display: none;"> </span></div>
<img style="height: 11in" src="graphic001.jpg">
</body>
</html>
Add an img tag for each graphic of a page that you want to output and make sure the name of the corresponding graphic file is given. Separate each graphic with a page break command as shown in the example.
Then convert the document to PDF from HTML:
wkhtmltopdf --enable-local-file-access document.html document.pdf
I need to upload a graphics file and send it to someone, but the application I'm uploading to is complaining that the graphic is too big.
You can use ImageMagick to resize an image in a variety of ways.
You can decrease the size of the image:
convert original.png -resize 50% new.png
You can resize the image to specific dimensions:
convert original.png -resize 64x64 new.png
How do I find out the size of an image so I can resize to a specific bit length and bit width?
Use ImageMagick's identify program:
identify original.png
GraphicsMagick is a fork of ImageMagick. The same tips work with GraphicsMagick. The only difference is the syntax. You need to run the gm program instead of separate programs like convert and identify. So add gm in front of any ImageMagick commands. For instance:
gm identify original.png