I have some tiff images that have an embedded color profile (the example one is Canon EOS-1Ds flash).
When I convert them to jpeg (gm convert source.tif target.jpeg) the resulting jpeg colours are distorted in browsers (Chrome,Firefox, but not IE) but not in system image viewers.
If I open the source in GIMP Image Editor, and change the colour profile to sRGB, then the image from the above convert command displays correctly in browsers.
So I have this question:
How can I identify the fact that an image has an embedded color
profile using graphicsmagick?
It looks like with this command the profile is removed:
mogrify +profile '*' -define jpeg:preserve-settings
Here is the output from gm identify -verbose source.tif
Image: Di 2007-1337.tif
Format: TIFF (Tagged Image File Format)
Geometry: 4053x2257
Class: DirectClass
Type: true color
Depth: 8 bits-per-pixel component
Channel Depths:
Red: 8 bits
Green: 8 bits
Blue: 8 bits
Channel Statistics:
Red:
Minimum: 0.00 (0.0000)
Maximum: 255.00 (1.0000)
Mean: 135.75 (0.5324)
Standard Deviation: 72.49 (0.2843)
Green:
Minimum: 0.00 (0.0000)
Maximum: 255.00 (1.0000)
Mean: 129.79 (0.5090)
Standard Deviation: 72.87 (0.2858)
Blue:
Minimum: 0.00 (0.0000)
Maximum: 255.00 (1.0000)
Mean: 125.43 (0.4919)
Standard Deviation: 73.42 (0.2879)
Resolution: 400x400 pixels/inch
Filesize: 26.4M
Interlace: No
Orientation: Unknown
Background Color: white
Border Color: #DFDFDF
Matte Color: #BDBDBD
Compose: Over
Dispose: Undefined
Iterations: 0
Compression: No
Signature: bec78e9402b39f6f5539a640715270a651a39c2238846fa42f37c1c7d99af747
Profile-color: 219244 bytes
Profile-iptc: 4358 bytes
unknown:
Byline:
Rod
Source:
Rod
Created Date:
20061006
Created Time:
110014+0000
Originating Program:
Capture One PRO
Program Version:
3.7.1
unknown:
0x00000000: ffffff5c 2c3bff65 2dffff39 ffffff55 ff5bff27 ----\,;-e---9---U-[-
0x00000014: ffffffff ff7affff ffffff48 103a29ff ff17ff58 '-----z-----H-:)----
0x00000028: ff616363 3dffffff ffffffff ff777a63 6537ff19 X-acc=--------wzce7-
0x0000003c: ffffffff 3c57ffff ff3c6674 ffff5f67 ff71ffff -----<W---<
0x00000050: 74ffff5f 67ff71ff ff00 ft--_
Tainted: False
User Time: 0.030u
Elapsed Time: 0:01
Pixels Per Second: 290.8M
The converted image from the following, is broken within OS image viewers as well:
Format: TIFF (Tagged Image File Format)
Geometry: 4992x3328
Class: DirectClass
Type: true color
Depth: 8 bits-per-pixel component
Channel Depths:
Red: 8 bits
Green: 8 bits
Blue: 8 bits
Channel Statistics:
Red:
Minimum: 0.00 (0.0000)
Maximum: 255.00 (1.0000)
Mean: 213.55 (0.8374)
Standard Deviation: 57.03 (0.2237)
Green:
Minimum: 0.00 (0.0000)
Maximum: 255.00 (1.0000)
Mean: 40.76 (0.1598)
Standard Deviation: 92.06 (0.3610)
Blue:
Minimum: 0.00 (0.0000)
Maximum: 255.00 (1.0000)
Mean: 161.49 (0.6333)
Standard Deviation: 121.23 (0.4754)
Resolution: 300x300 pixels/inch
Filesize: 47.6M
Interlace: No
Orientation: TopLeft
Background Color: white
Border Color: #DFDFDF
Matte Color: #BDBDBD
Compose: Over
Dispose: Undefined
Iterations: 0
Compression: No
Artist: Gary
Timestamp: 2006:11:12 12:35:12
Make: Canon
Model: Canon EOS-1Ds Mark II
Software: Adobe Photoshop CS2 Macintosh
Signature: 1b26f2c2122ea6aa391a40c7eb885d0da120x8e9x5bd7ce0dc7cc9038ba99737
Profile-iptc: 12926 bytes
unknown:
Byline:
Gary Ombler
Originating Program:
Capture One PRO
Program Version:
3.7.3
unknown:
#Q�$�'���߸︥�[��Rҝ5��n�b����h�
Profile-XMP: 17293 bytes
Tainted: False
User Time: 0.140u
Elapsed Time: 0:01
Pixels Per Second: 45.3M
gm identify -verbose *.tif | egrep -a '^Image|Profile-'
This will print all matching filenames, followed by the profiles for those files that have them. This would at least let you scan a directory at a time and try to figure out why some files are problematic.
Perhaps you may force the colorspace to RGB:
gm convert +profile "*" -colorspace RGB source destination
Related
I have a webm file which include audio data(using opus codec).
I want to use libwebm parser, but I cant find infor about that, and I dont know how to do.
there is a few sample code.
anyway I succeed to parse(just do by the sample code)
but that is just only print, parsing is ok.
I want ther really audio data, but dont know how can I get it.
below linke is demo code which i used.
https://github.com/webmproject/libwebm/blob/master/webm_parser/demo/demo.cc
and below is the results.
how can I get the audio data??
EBML header: [0, 5) body: [5, 36)
EBMLVersion: 1
EBMLReadVersion: 1
EBMLMaxIDLength: 4
EBMLMaxSizeLength: 8
DocType: webm
DocTypeVersion: 4
DocTypeReadVersion: 2
Segment header: [36, 48) body: [48, ?)
Info header: [48, 53) body: [53, 78)
TimecodeScale: 1000000
MuxingApp: Chrome
WritingApp: Chrome
Tracks header: [78, 83) body: [83, 146)
TrackEntry header: [83, 85) body: [85, 146)
TrackNumber: 1
TrackUID: 15362115268361576
TrackType: 2 (audio)
FlagEnabled (implicit): 1
FlagDefault (implicit): 1
FlagForced (implicit): 0
FlagLacing (implicit): 1
CodecID: A_OPUS
CodecPrivate: <19 bytes>
SeekPreRoll (implicit): 0
Audio
SamplingFrequency: 48000
Channels: 1
BitDepth: 32
Cluster header: [146, 158) body: [158, ?)
Timecode: 0
SimpleBlock header: [161, 164) body: [164, 1419)
track number: 1
frames: 1
timecode: 0
lacing: 0 (none)
flags: visible, key frame
frame byte range: [168, 1419)
SimpleBlock header: [1419, 1422) body: [1422, 2427)
track number: 1
frames: 1
timecode: 59
lacing: 0 (none)
flags: visible, key frame
frame byte range: [1426, 2427)
SimpleBlock header: [2427, 2430) body: [2430, 3396)
I am trying to convert a rgb image to cmyk using profiles I downloaded from the adobe website.
The command I am using is as follow:
convert Playbook.jpg -profile CoatedFOGRA27.icc cmyk_playbook.jpg
When I try to open the output image on photoshop, I get a error that it's impossible to use the ICC profile incorporated, because the profile ICC is incorrect. The profile will be ignored.
When I check the -verbose of the image using the identity command I get the colorspace as sRGB. I could see that the color profiles were added to the image. But I don't understand how adobe ps does it differently. Adding a -colorspace CMYK will change the colorspace from -sRGB to CMYK, but the results are not good. The colors in the output are not even close to the real input.
C:\test\profile>magick identify -verbose cmyk_playbook.jpg
Image: cmyk_playbook.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 969x301+0+0
Resolution: 72x72
Print size: 13.4583x4.18056
Units: PixelsPerInch
Type: TrueColor
Endianess: Undefined
**Colorspace: sRGB**
icc:copyright: Copyright 2004-2007 Adobe Systems Incorporated
icc:description: Coated FOGRA27 (ISO 12647-2:2004)
icc:manufacturer: Coated FOGRA27 (ISO 12647-2:2004)
icc:model: Coated FOGRA27 (ISO 12647-2:2004)
I'm new to icc profiles and any help would be appreciated. Please let me know if you need any info regarding the test done here. I am referring to a imagemagick usage guide for my tests imagemagick color profile
EDIT 2
As per Fred's comments, I had better results when I modified imagemagick string to (referred from the imagemagick profile's section)
magick convert Playbook.jpg -profile AdobeRGB1998.icc -profile CoatedFOGRA39.icc cmyk_playbook.jpg
-verbose of output image at link https://textuploader.com/dvbyp
EDIT 3
Verbose of the input image
> C:\test\profile>magick identify -verbose Playbook.jpg
Image: Playbook.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Mime type: image/jpeg
Class: DirectClass
Geometry: 969x301+0+0
Resolution: 72x72
Print size: 13.4583x4.18056
Units: PixelsPerInch
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
Red: 8-bit
Green: 8-bit
Blue: 8-bit
Channel statistics:
Pixels: 291669
Red:
min: 0 (0)
max: 255 (1)
mean: 194.392 (0.762322)
standard deviation: 83.2222 (0.326362)
kurtosis: 0.704344
skewness: -1.52406
entropy: 0.788734
Green:
min: 0 (0)
max: 255 (1)
mean: 212.207 (0.832184)
standard deviation: 48.3621 (0.189655)
kurtosis: 1.86417
skewness: -1.56849
entropy: 0.805723
Blue:
min: 0 (0)
max: 255 (1)
mean: 212.778 (0.834423)
standard deviation: 50.177 (0.196772)
kurtosis: 2.14027
skewness: -1.61153
entropy: 0.817837
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 206.459 (0.809643)
standard deviation: 63.2485 (0.248033)
kurtosis: 2.77398
skewness: -1.87528
entropy: 0.804098
Rendering intent: Perceptual
Gamma: 0.454545
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Matte color: grey74
Background color: white
Border color: srgb(223,223,223)
Transparent color: none
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 969x301+0+0
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 99
Orientation: TopLeft
Properties:
date:create: 2018-09-24T13:58:23+02:00
date:modify: 2018-09-07T12:10:45+02:00
exif:ColorSpace: 65535
exif:DateTime: 2018:05:22 10:58:52
exif:ExifImageLength: 301
exif:ExifImageWidth: 969
exif:ExifOffset: 168
exif:Orientation: 1
exif:ResolutionUnit: 2
exif:Software: Adobe Photoshop CC (Macintosh)
exif:thumbnail:Compression: 6
exif:thumbnail:JPEGInterchangeFormat: 306
exif:thumbnail:JPEGInterchangeFormatLength: 3377
exif:thumbnail:ResolutionUnit: 2
exif:thumbnail:XResolution: 72/1
exif:thumbnail:YResolution: 72/1
exif:XResolution: 720000/10000
exif:YResolution: 720000/10000
jpeg:colorspace: 2
jpeg:sampling-factor: 1x1,1x1,1x1
signature: ca4b1e91d7efa6044dca943ef7bd15b562190d821b86ce25ad55f3150100150e
Clipping path:
<?xml version="1.0" encoding="iso-8859-1"?>
<svg xmlns="http://www.w3.org/2000/svg" width="969" height="301">
<g>
<path fill-rule="evenodd" style="fill:#00000000;stroke:#00000000;stroke-width:0;
stroke-antialiasing:false" d="
M 342 56
L 363 56
L 438 55
L 452 52
L 475 49
L 491 46
L 510 39
L 526 33
L 544 26
L 554 18
C 554 18 557.982 -3.60937 556 -6.00001
C 554.018 -8.39063 527.42 -31.6426 525 -32
C 522.58 -32.3574 455.445 -39.2773 450 -39
C 444.555 -38.7226 388.031 -37.0664 386 -36
C 383.969 -34.9336 345.721 -11.0879 344 -8
C 342.279 -4.9121 332.74 22.6133 333 26
C 333.26 29.3867 342 56 342 56 Z
"/>
</g>
</svg>
Profiles:
Profile-8bim: 11730 bytes
Profile-exif: 3689 bytes
Profile-iptc: 95 bytes
City[1,90]: 0x00000000: 254700 -%
City[1,90]: 0x00000000: 254700 -%
City[1,90]: 0x00000000: 254700 -%
City[1,90]: 0x00000000: 254700 -%
City[1,90]: 0x00000000: 254700 -%
City[1,90]: 0x00000000: 254700 -%
City[1,90]: 0x00000000: 254700 -%
City[1,90]: 0x00000000: 254700 -%
City[1,90]: 0x00000000: 254700 -%
City[1,90]: 0x00000000: 254700 -%
City[1,90]: 0x00000000: 254700 -%
unknown[2,0]:
Profile-xmp: 1241722 bytes
Artifacts:
verbose: true
Tainted: False
Filesize: 1.458MB
Number pixels: 292K
Pixels per second: 4.704MB
User time: 0.047u
Elapsed time: 0:01.062
Version: ImageMagick 7.0.5-4 Q16 x64 2017-03-25 http://www.imagemagick.org
I have different raster bands and I need to get a proper image from these bands using OpenCV. How can it be done?
As an alternative to my other answer, you could put a small ASCII header on your raw files to make them into PGM files which OpenCV can read natively without any extra libraries. The PGM format is part of the NetPBM suite described here on Wikipedia.
So, let's say each of your rasters is a single channel, 8-bit image with dimensions 100 px wide by 256 px tall. Make each band into a PGM image in the Terminal:
{ printf "P5\n100 256\n255\n"; cat band1.dat; } > band1.pgm
{ printf "P5\n100 256\n255\n"; cat band2.dat; } > band2.pgm
{ printf "P5\n100 256\n255\n"; cat band3.dat; } > band3.pgm
{ printf "P5\n100 256\n255\n"; cat band4.dat; } > band4.pgm
You now have 4 greyscale images you can view with GIMP or feh and, more importantly which OpenCV can read. So your code becomes:
Mat b1 = imread("band1.pgm", IMREAD_UNCHANGED);
Mat b2 = imread("band2.pgm", IMREAD_UNCHANGED);
Mat b3 = imread("band3.pgm", IMREAD_UNCHANGED);
Mat b4 = imread("band4.pgm", IMREAD_UNCHANGED);
// Now merge
auto channels = std::vector<cv::Mat>{b1, b2, b3, b4};
cv::Mat FourBandBoy;
cv::merge(channels, FourBandBoy);
As you haven't provided any sample raster images, I made 4 images, each 100x256, for a quick demonstration. Here they are:
-rw-r--r-- 1 mark staff 25600 21 Mar 10:44 band1.dat
-rw-r--r-- 1 mark staff 25600 21 Mar 10:44 band2.dat
-rw-r--r-- 1 mark staff 25600 21 Mar 10:44 band3.dat
-rw-r--r-- 1 mark staff 25600 21 Mar 10:44 band4.dat
Hopefully, you can see from the sizes that they are 100x256, single channel and 8-bit.
I the converted them to PGM per the original instructions:
{ printf "P5\n100 256\n255\n"; cat band1.dat; } > band1.pgm
{ printf "P5\n100 256\n255\n"; cat band2.dat; } > band2.pgm
{ printf "P5\n100 256\n255\n"; cat band3.dat; } > band3.pgm
{ printf "P5\n100 256\n255\n"; cat band4.dat; } > band4.pgm
which gives:
-rw-r--r-- 1 mark staff 25615 21 Mar 10:44 band1.pgm
-rw-r--r-- 1 mark staff 25615 21 Mar 10:44 band2.pgm
-rw-r--r-- 1 mark staff 25615 21 Mar 10:44 band3.pgm
-rw-r--r-- 1 mark staff 25615 21 Mar 10:44 band4.pgm
So, you can see the PGM header amounts to 15 bytes. The images look like this now:
I slightly modified the code:
#include <iostream>
#include <opencv2/opencv.hpp>
#include <cstdio>
using namespace cv;
using namespace std;
int
main(int argc,char*argv[])
{
Mat b1 = imread("band1.pgm", IMREAD_UNCHANGED);
Mat b2 = imread("band2.pgm", IMREAD_UNCHANGED);
Mat b3 = imread("band3.pgm", IMREAD_UNCHANGED);
Mat b4 = imread("band4.pgm", IMREAD_UNCHANGED);
// Now merge
auto channels = std::vector<cv::Mat>{b1,b2,b3,b4};
cv::Mat BigBoy;
cv::merge(channels, BigBoy);
// Save
cv::imwrite("result.png",BigBoy);
}
And the result...
Hopefully you can see that the resulting image:
is blue where there was a lot of white in band1,
is green where there was a lot of white in band2,
is red where band3 was white
is transparent where band 4 was black
I don't feel like writing all the code and testing it like I ordinarily might so I'll just give you an outline of one way to do it.
Assume your images are WIDTHxHEIGHT in dimension and made of unsigned char data written consecutively without padding into files called band1.dat, band2.dat etc.
// Step 1: Allocate a buffer: raw = WIDTHxHEIGHT bytes
// Step 2: Load one band from disk into raw buffer
open band1.dat, read WIDTH*HEIGHT bytes into raw, close band1.dat
// Make a single band Mat from that data
cv::Mat band1(HEIGHT,WIDTH,CV_8UC1);
// Copy the raw data into it so we can re-use buffer
std::memcpy(band1.data,raw,WIDTH*HEIGHT);
// Repeat step 2 for bands 2-4 so you have 4 separate, single channel Mats
// Now merge the 4 individual channels into 4-band bad boy
auto channels = std::vector<cv::Mat>{band1, band2, band3, band4};
cv::Mat FourBandBoy;
cv::merge(channels, FourBandBoy);
First of all, my question is different to How do I convert image to 2-bit per pixel? and unfortunately its solution does not work in my case...
I need to convert images to 2-bit per pixel grayscale BMP format. The sample image has the following properties:
Color Model: RGB
Depth: 4
Is Indexed: 1
Dimension: 800x600
Size: 240,070 bytes (4 bits per pixel but only last 2 bits are used to identify the gray scales as 0/1/2/3 in decimal or 0000/0001/0010/0011 in binary, plus 70 bytes BMP metadata or whatever)
The Hex values of the beginning part of the sample BMP image:
The 3s represent white pixels at the beginning of the image. Further down there are some 0s, 1s and 2s representing black, dark gray and light gray:
With the command below,
convert pic.png -colorspace gray +matte -depth 2 out.bmp
I can get visually correct 4-level grayscale image, but wrong depth or size per pixel:
Color Model: RGB
Depth: 8 (expect 4)
Dimension: 800x504
Size: 1,209,738 bytes (something like 3 bytes per pixel, plus metadata)
(no mention of indexed colour space)
Please help...
OK, I have written a Python script following Mark's hints (see comments under original question) to manually create a 4-level gray scale BMP with 4bpp. This specific BMP format construction is for the 4.3 inch e-paper display module made by WaveShare. Specs can be found here: http://www.waveshare.com/wiki/4.3inch_e-Paper
Here's how to pipe the original image to my code and save the outcome.
convert in.png -colorspace gray +matte -colors 4 -depth 2 -resize '800x600>' pgm:- | ./4_level_gray_4bpp_BMP_converter.py > out.bmp
Contents of 4_level_gray_4bpp_BMP_converter.py:
#!/usr/bin/env python
"""
### Sample BMP header structure, total = 70 bytes
### !!! little-endian !!!
Bitmap file header 14 bytes
42 4D "BM"
C6 A9 03 00 FileSize = 240,070 <= dynamic value
00 00 Reserved
00 00 Reserved
46 00 00 00 Offset = 70 = 14+56
DIB header (bitmap information header)
BITMAPV3INFOHEADER 56 bytes
28 00 00 00 Size = 40
20 03 00 00 Width = 800 <= dynamic value
58 02 00 00 Height = 600 <= dynamic value
01 00 Planes = 1
04 00 BitCount = 4
00 00 00 00 compression
00 00 00 00 SizeImage
00 00 00 00 XPerlPerMeter
00 00 00 00 YPerlPerMeter
04 00 00 00 Colours used = 4
00 00 00 00 ColorImportant
00 00 00 00 Colour definition index 0
55 55 55 00 Colour definition index 1
AA AA AA 00 Colour definition index 2
FF FF FF 00 Colour definition index 3
"""
# to insert File Size, Width and Height with hex strings in order
BMP_HEADER = "42 4D %s 00 00 00 00 46 00 00 00 28 00 00 00 %s %s 01 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 55 55 55 00 AA AA AA 00 FF FF FF 00"
BMP_HEADER_SIZE = 70
BPP = 4
BYTE = 8
ALIGNMENT = 4 # bytes per row
import sys
from re import findall
DIMENTIONS = 1
PIXELS = 3
BLACK = "0"
DARK_GRAY = "1"
GRAY = "2"
WHITE = "3"
# sample data:
# ['P5\n', '610 590\n', '255\n', '<1 byte per pixel for 4 levels of gray>']
# where item 1 is always P5, item 2 is width heigh, item 3 is always 255, items 4 is pixels/colours
data = sys.stdin.readlines()
width = int(data[DIMENTIONS].strip().split(' ')[0])
height = int(data[DIMENTIONS].strip().split(' ')[1])
if not width*height == len(data[PIXELS]):
print "Error: pixel data (%s bytes) and image size (%dx%d pixels) do not match" % (len(data[PIXELS]),width,height)
sys.exit()
colours = [] # enumerate 4 gray levels
for p in data[PIXELS]:
if not p in colours:
colours.append(p)
if len(colours) == 4:
break
# it's possible for the converted pixels to have less than 4 gray levels
colours = sorted(colours) # sort from low to high
# map each colour to e-paper gray indexes
# creates hex string of pixels
# e.g. "0033322222110200....", which is 4 level gray with 4bpp
if len(colours) == 1: # unlikely, but let's have this case here
pixels = data[PIXELS].replace(colours[0],BLACK)
elif len(colours) == 2: # black & white
pixels = data[PIXELS].replace(colours[0],BLACK)\
.replace(colours[1],WHITE)
elif len(colours) == 3:
pixels = data[PIXELS].replace(colours[0],DARK_GRAY)\
.replace(colours[1],GRAY)\
.replace(colours[2],WHITE)
else: # 4 grays as expected
pixels = data[PIXELS].replace(colours[0],BLACK)\
.replace(colours[1],DARK_GRAY)\
.replace(colours[2],GRAY)\
.replace(colours[3],WHITE)
# BMP pixel array starts from last row to first row
# and must be aligned to 4 bytes or 8 pixels
padding = "F" * ((BYTE/BPP) * ALIGNMENT - width % ((BYTE/BPP) * ALIGNMENT))
aligned_pixels = ''.join([pixels[i:i+width]+padding for i in range(0, len(pixels), width)][::-1])
# convert hex string to represented byte values
def Hex2Bytes(hexStr):
hexStr = ''.join(hexStr.split(" "))
bytes = []
for i in range(0, len(hexStr), 2):
byte = int(hexStr[i:i+2],16)
bytes.append(chr(byte))
return ''.join(bytes)
# convert integer to 4-byte little endian hex string
# e.g. 800 => 0x320 => 00000320 (big-endian) =>20030000 (little-endian)
def i2LeHexStr(i):
be_hex = ('0000000'+hex(i)[2:])[-8:]
n = 2 # split every 2 letters
return ''.join([be_hex[i:i+n] for i in range(0, len(be_hex), n)][::-1])
BMP_HEADER = BMP_HEADER % (i2LeHexStr(len(aligned_pixels)/(BYTE/BPP)+BMP_HEADER_SIZE),i2LeHexStr(width),i2LeHexStr(height))
sys.stdout.write(Hex2Bytes(BMP_HEADER+aligned_pixels))
Edit: everything about this e-paper display and my code to display things on it can be found here: https://github.com/yy502/ePaperDisplay
This works for me in Imagemagick 6.9.10.23 Q16 Mac OSX Sierra
Input:
convert logo.png -colorspace gray -depth 2 -type truecolor logo_depth8_gray_rgb.bmp
Adding -type truecolor converts the image to RGB, but in gray tones as per the -colorspace gray. And the depth 2 creates only 4 colors in the histogram.
identify -verbose logo_depth8_gray_rgb.bmp
Image:
Filename: logo_depth8_gray_rgb.bmp
Format: BMP (Microsoft Windows bitmap image)
Class: DirectClass
Geometry: 640x480+0+0
Units: PixelsPerCentimeter
Colorspace: sRGB
Type: Grayscale
Base type: Undefined
Endianness: Undefined
Depth: 8/2-bit
Channel depth:
red: 2-bit
green: 2-bit
blue: 2-bit
Channel statistics:
Pixels: 307200
Red:
min: 0 (0)
max: 255 (1)
mean: 228.414 (0.895742)
standard deviation: 66.9712 (0.262632)
kurtosis: 4.29925
skewness: -2.38354
entropy: 0.417933
Green:
min: 0 (0)
max: 255 (1)
mean: 228.414 (0.895742)
standard deviation: 66.9712 (0.262632)
kurtosis: 4.29925
skewness: -2.38354
entropy: 0.417933
Blue:
min: 0 (0)
max: 255 (1)
mean: 228.414 (0.895742)
standard deviation: 66.9712 (0.262632)
kurtosis: 4.29925
skewness: -2.38354
entropy: 0.417933
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 228.414 (0.895742)
standard deviation: 66.9712 (0.262632)
kurtosis: 4.29928
skewness: -2.38355
entropy: 0.417933
Colors: 4 <--------
Histogram: <--------
12730: (0,0,0) #000000 black
24146: (85,85,85) #555555 srgb(85,85,85)
9602: (170,170,170) #AAAAAA srgb(170,170,170)
260722: (255,255,255) #FFFFFF white
Look at https://en.wikipedia.org/wiki/BMP_file_format#File_structure .
The problem is that you do not specify a color table. According to the wikipedia-article, those are mandatory if the bit depth is less than 8 bit.
Well done on solving the problem. You could consider also making a personal delegate, or custom delegate, for ImageMagick to help automate the process. ImageMagick is able to delegate formats it cannot process itself to delegates, or helpers, such as your 2-bit helper ;-)
Rather than interfere with the system-wide delegates, which probably live in /etc/ImageMagick/delegates.xml, you can make your own in $HOME/.magick/delegates.xml. Yours would look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<delegatemap>
<delegate encode="epaper" command="convert "%f" +matte -colors 4 -depth 8 -colorspace gray pgm:- | /usr/local/bin/4_level_gray_4bpp_BMP_converter.py > out.bmp"/>
</delegatemap>
Then if you run:
identify -list delegate
you will see yours listed as a "known" helper.
This all means that you will be able to run commands like:
convert a.png epaper:
and it will do the 2-bit BMP thing automagically.
You can just use this:
convert in.jpg -colorspace gray +matte -colors 2 -depth 1 -resize '640x384>' pgm:- > out.bmp**
I too have this epaper display. After alot of trial and error, I was able to correctly convert the images using ImageMagick using the following command:
convert -verbose INPUT.BMP -resize 300x300 -monochrome -colorspace sRGB -colors 2 -depth 1 BMP3:OUTPUT.BMP
Is the code below the correct format for number_to_human_size? I placed them under five, [en:, es:, de:, it:, fr:] .yml files.
storage_units:
format: "%n %u"
units:
byte:
one: "Byte"
other: "Bytes"
kb: "KB"
mb: "MB"
gb: "GB"
tb: "TB"
I have following reference
<%= number_to_human_size(#game.downloadsize, :precision => 2, :locale=>I18n.locale) %>
I am getting the error message:
can not load translations from C:/Documents and Settings/rajg/antixdiscoveraws/config/locales/de.yml, expected it to return a hash, but does not
Any help is much appreciated.
Try to indent the format:
storage_units:
format: "%n %u"
units:
byte:
one: "Byte"
other: "Bytes"
kb: "KB"
mb: "MB"
gb: "GB"
tb: "TB"