QR Code MIME Type - mime-types

Is there a commonly recognised MIME type specifically for QR code images, beyond the generic image/png (assuming png is the format)?

No. A QR Code isn't a file type any more than a barcode. The MIME type should be that of the file containing the QR Code.

a qr code is just the code, not the file format.
you could save it as a bmp, jpeg, gif and it would still work.
but png works best for qr codes because of the way it compresses, plus its lossless so it scales without blurring.
heres why.
jpg is a lossy format, meaning you loose quality with compression. it is geared for full color photographs.
bmp is lossy but and is also geared to photographs, it can be lossless but the file is huge.
png, is lossless, compression is done similar to a zip archive. it is geared to simple images, but can handle complex images. it is not meant for photographs. and works wonderfully with qr codes.
PNG can be compressed by removing colors from the color index.
to start with i created a barcode with zint with the URl of this question QR Code MIME Type
next i opened it in gimp and saved it as a bmp its file size was 129 KB for the bmp i left all options at default in gimp.
a JPG at 100 % quality resulted in a 21.4 KB file
a jpg at 75 % quality resulted in a file size of 12.3 KB
a jpg with 50% quality resulted in a size of 9.90 KB
a jpg with 20% quality resulted in a size of 7.79 KB
a GIF with default settings resulted in a size of 2.43 KB
a PNG with the default options resulted in 1.12 KB
a optimised PNG (Using R.I.O.T) resulted in a file size of 420 bytes
for reference my riot settings were
color reduction = dithered monochrome
compression maximum
heres the BMP
heres the JPG # 25%
heres the gif
heres the PNG at default settings
heres the optimised PNG
scan any of these and they will work (a more compressed jpg may not work because of the introduced noise)

Related

BMP file formats and edge detection

I came across this excellent tutorial on image processing by Bill Green - http://dasl.mem.drexel.edu/alumni/bGreen/www.pages.drexel.edu/_weg22/edge.html
He works with BMP formats in the tutorial since they are the simplest. I tried the sobel edge detection code, got it to compile and run. When I try this on the images on that web site (for example, LIAG.bmp, the photo of the lady), the code works just fine. However, when I get other .bmp images (for example, take any image and convert it at - http://www.online-convert.com/result/6c0ce763b5e6cadf3a76a966acdb9505) and the code spits out an image that can't be read by any image editor. The issue is most probably in the line -
nColors = (int)getImageInfo(bmpInput, 46, 4);
of his code. There seems to be some hard coding here which only works on the image sizes on his tutorial. The nColors variable is 256 for all images on his site, but 0 for all images I get otherwise. Can any one tell me how I might change this piece of code to generalize this?
The 46 in this line:
nColors = (int)getImageInfo(bmpInput, 46, 4);
...refers to the bit offset into the header of the BMP. Unless you are creating BMPs that do not use this file structure it should theoretically work. He is referring to 8-bit images on that page. Perhaps, 16 or 32-bit images use a different file structure for the header.
Read this Wikipedia page for more info: https://en.wikipedia.org/wiki/BMP_file_format#File_structure

RGB pictures detected as YCbCr with libjpeg-turbo

I'm using libjpeg-turbo to open jpeg pictures in a C program. Pictures in RGB colorspace are detected as YCbCr. Grayscale and CMYK colorspaces are correctly detected.
I though about a problem related to 2 different versions of jpeglib.h (where J_COLOR_SPACE enum is defined) or libjpeg conflicting with libjpeg-turbo, but there is just one jpeglib.h on the environment I'm using for compiling libjpeg-turbo and my program.
Any idea much appreciated.

What image formats are supported by Gdk-Pixbuf (Gtk-Image?) by Default?

I know that Gdk-Pixbuf supports png and jpg, but I cannot find an exact list of all the completely (or partially) supported image formats anywhere on the internet. It is necessary for my current project, since I need to check the extension of every file in a directory and determine whether it is supported or not by gdk-pixbuf. Any help?
I know this is 5+ years old but I had trouble finding this for PyGI / PyGObject (3.22.0).
import gi.repository.GdkPixbuf as pixbuf
Then we can get all the formats using:
for f in pixbuf.Pixbuf.get_formats():
print f.get_name()
On my system (might be different on yours if you installed other loaders), I get:
ani
bmp
GdkPixdata
gif
icns
ico
jpeg
png
pnm
qtif
svg
tga
tiff
wmf
xbm
xpm
Calling gdk_pixbuf_get_formats() in your application will tell you which formats your copy of GDKPixbuf can load.
This should be available by querying gdk-pixbuf-loaders.
Here is more information on pixbuf modules and supported formats.

Getting the pixel value of BMP file

i got a question for reading an bmp image. How can i get the pixel value(R, G, B values) in an bmp image?
Can anyone help me using the C programming language?
Note: you may need to grab an extra byte for the alpha values if your BMP has alpha channel. In that case image would be image[pixelcount][4], and you would add another getc(streamIn) line to hold that fourth index. My BMP turned out to not need that.
// super-simplified BMP read algorithm to pull out RGB data
// read image for coloring scheme
int image[1024][3]; // first number here is 1024 pixels in my image, 3 is for RGB values
FILE *streamIn;
streamIn = fopen("./mybitmap.bmp", "r");
if (streamIn == (FILE *)0){
printf("File opening error ocurred. Exiting program.\n");
exit(0);
}
int byte;
int count = 0;
for(i=0;i<54;i++) byte = getc(streamIn); // strip out BMP header
for(i=0;i<1024;i++){ // foreach pixel
image[i][2] = getc(streamIn); // use BMP 24bit with no alpha channel
image[i][1] = getc(streamIn); // BMP uses BGR but we want RGB, grab byte-by-byte
image[i][0] = getc(streamIn); // reverse-order array indexing fixes RGB issue...
printf("pixel %d : [%d,%d,%d]\n",i+1,image[i][0],image[i][1],image[i][2]);
}
fclose(streamIn);
~Locutus
The easy way would be to find a good image manipulation library for your chosen platform and use that.
Linux ImLib / GDK-Pixbuf (Gnome/GTK) / QT Image (KDE/Qt) should be able to do what you need.
Windows I'm not familiar with the appropriate system library, but an MSDN Search for "Bitmap" is probably a good place to start.
Mac OSX Cocoa has some image manipulation capabilities, see this article.
The hard way would be to open the file and actually interpret the binary data within. To do that you'll need the BMP File Specification. I'd recommend trying the easy way first.
You need to study the BMP file format. It is easier to read uncompressed 24-bit BMP files. They just contain a header at the beginning and RGB values of each pixel.
To start with this, check the example of 2x2 bitmap image at http://en.wikipedia.org/wiki/BMP_file_format. Follow the below steps.
Create the 2x2 BMP image shown on Wikipedia.
Open the file in binary mode using your C program.
Seek to byte position 54.
Read 3 bytes.
The bytes would be 0, 0 and 255 respectively. (Not sure whether the order is RGB. I had done this long back and I think the order is not RGB. Just verify this.)
As simple as that! Study the header of the BMP to understand more about the format.

Extracting Spot Color equivalents from TIFF

I'm trying to get the Spot color information from a TIFF file, it normally shows up under 'channels' in Photoshop. Each extra channel would have a name, which is usually a Pantone swatch name, and a CMYK equivalent.
So far, I'm getting the TIFFTAG_PHOTOSHOP with libtiff, and stepping through the blocks within. I'm finding the IRB WORD 0x03EE, which gives me the channel names, and IRB WORD 0x03EF which gives me their color equivalents...
BUT the color equivalents are in CIELab format (Luminance, and two axis of color space data) so I'm trying to use littleCMS to convert just a few TIFF packed Lab color to CMYK.
My question: Is there an easier way? The CMYK is just an approximation of the Pantone, so if there was a quick rough translation from Lab to CMYK, I would use it.
The answer was to use the photoshop docs to parse out the binary photoshop block in the tiff file and grab the fields I needed with bit manipulation.
littleCMS did the job of LAB -> CMYK just right.

Resources