Smokes your problems, coughs fresh air.

Tag: PNG

ImageMagick can convert PDF to anything

I encountered one of those scans which was shared as a single-page PDF. I don’t want it that way, because I want to include it in a web page. I want a simple bitmap image. ImageMagick comes to the rescue:

convert scan.pdf scan.jpg

If the resolution this produces is too low for you, try telling Ghostscript (which ImageMagick uses internally) that you want a different density:

convert -density 300 scan.pdf scan.jpg


Googling linux pdf to jpg produced two useful results:

  1. Batch converting PDF to JPG/JPEG using free software
  2. Converting PDF to PNG/JPG using ImageMagick in Linux

png2ico: converting favicons to Windows’ ICO format

Even though, strictly speaking, I should be using favicons in anything but Windows’ ICO format and refer to them from a <link>-tag at any location other than /favicon.ico, I sometimes like to help Microsoft break the web by putting an ICO file at the location that they reserved for it (/favicon.ico).

My tool of choice for converting PNG’s to ICO is Matthias Benkmann’s png2ico. To generate an ICO file with this program, you just need to feed it one or more PNG files. The possibility to include differently sized PNG files can help you make sure that the icon will steal look good when being dragged to the desktop or some other non-miniature context.

$ png2ico
png2ico 2002-12-08  (c) Matthias S. Benkmann
USAGE: png2ico icofile [--colors ] pngfile1 [pngfile2 ...]

Here’s an actual example which creates an ICO file from a single PNG file:

$ file favicon.png 
favicon.png: PNG image data, 16 x 16, 8-bit/color RGBA, non-interlaced
$ png2ico favicon.ico favicon.png 

Of course, we should discourage browsers from doing useless requests for /favicon.ico by actually telling them when it is available: (as if…)

<link type="image/x-icon" rel="shortcut icon" href="/favicon.ico" />

Now we can go back to pretending that: No, we’re not encouraging the practice of link squatting. We just happen to have put our favicon in that location.

For the less tech savvy

Update 30 sep 2012: There’s a free online service to convert PNG to ICO: It doesn’t require you to do anything complicated (like installing Unix stuff). Just pick your original and get the converted image. 🙂

Scaling bitmap graphics versus scaling vector graphics

Due to some organizational changes, past December, I had to remove the S.A. suffix from the Sicirec logo:

Sicirec logo with “S.A.” - scaled some time earlier
The original logo with the “S.A.” suffix intact.

After removing the S.A. suffix from the vector file in Illustrator’s vector format, I wanted to export the logo to a small PNG again. Annoyingly, though, the PNG—if I wanted Illustrator to respect the correct aspect ratio—could not be the same width as the original PNG if I gave it the same height; it would always be one pixel higher. If, however, I exported it as a huge PNG corresponding to the vector’s original dimensions and scaled it down in The GIMP, the dimensions turned out about the same.

It was then that I noticed that The GIMP’s scaling algorithm is actually very decent. From just looking at the two images below, you need a moment or two to notice that one is a little sharper than the other. Obviously, that’s the Illustrator version.

Sicirec logo without “S.A.” - scaled in The GIMP Sicirec logo without “S.A.” - scaled in Adobe Illustrator

In the end, though, neither version integrated easily with the complex layout which I had based around the logo image, so I simply opened the existing PNG image in The GIMP and erased the S.A. suffix.

Sicirec logo with the “S.A.” suffix removed in The GIMP
The original PNG after the GIMP treatment.

I still don’t understand why I couldn’t repeat the scaling result of the original image in Illustrator. But, I’ve probably wasted enough time on a rounding issue that isn’t even an issue…

© 2024 BigSmoke

Theme by Anders NorenUp ↑