When to interlace an image?

JPEG: YES — use progressive scan. It makes files smaller (each pass gets its own Huffman table), and partial rendering looks quite good. GIF: NO — it’s unlikely to make the file smaller, partial rendering is poor, and it’s pointless for animGIFs. It’s best not to use GIF at all (yes, even for anims). PNG: … Read more

Efficient JPEG Image Resizing in PHP

People say that ImageMagick is much faster. At best just compare both libraries and measure that. Prepare 1000 typical images. Write two scripts — one for GD, one for ImageMagick. Run both of them a few times. Compare results (total execution time, CPU and I/O usage, result image quality). Something which the best everyone else, … Read more

Is it possible to tell the quality level of a JPEG?

You can view compress level using the identify tool in ImageMagick. Download and installation instructions can be found at the official website. After you install it, run the following command from the command line: identify -format ‘%Q’ yourimage.jpg This will return a value from 0 (low quality, small filesize) to 100 (high quality, large filesize). … Read more

Is JPEG lossless when quality is set to 100?

As correctly answered above, using a “typical” JPEG encoder at quality 100 does not give you lossless compression. Lossless JPEG encoding exists, but it’s different in nature and seldom used. I’m just posting to say why quality 100 does not mean lossless. In JPEG compression information is mostly lost during the DCT coefficient quantization step … Read more

When to use PNG or JPG in iPhone development?

PNG’s are pixel perfect (non-lossy), and require very little extra CPU energy to display. However, large PNGs may take longer to read from storage than more compressed image formats, and thus be slower to display. JPG’s are smaller to store, but lossy (amount depends on compression level), and to display them requires a much more … Read more

Convert SVG image to PNG with PHP

That’s funny you asked this, I just did this recently for my work’s site and I was thinking I should write a tutorial… Here is how to do it with PHP/Imagick, which uses ImageMagick: $usmap = ‘/path/to/blank/us-map.svg’; $im = new Imagick(); $svg = file_get_contents($usmap); /*loop to color each state as needed, something like*/ $idColorArray = … Read more

Convert RGBA PNG to RGB with PIL

Here’s a version that’s much simpler – not sure how performant it is. Heavily based on some django snippet I found while building RGBA -> JPG + BG support for sorl thumbnails. from PIL import Image png = Image.open(object.logo.path) png.load() # required for png.split() background = Image.new(“RGB”, png.size, (255, 255, 255)) background.paste(png, mask=png.split()[3]) # 3 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)