2016-01-19 28 views
7

Gri ​​tonlamalı görüntüleri imagemagick command-line tools kullanarak RGB'ye dönüştürmeye çalışıyorum.JPG görüntüsünü gri tonlamadan RGB'ye dönüştürün imagemagick

O kullanarak, PNG görüntüler için iyi çalışıyor

:

convert image.png -define png:color-type=2 result.png 

("How to convert gray scale png image to RGB from comand line using image magick" bir cevap alınmıştır) identify -format %r result.png ile kontrol hala DirectClass Grey dönecektir rağmen, işe yaradı görebilirsiniz Şu an bantları/kanalları listelendiğinden gdalinfo kullanarak:

gdalinfo [başarıyla dönüştürülmüş PNG]:

Driver: PNG/Portable Network Graphics 
Files: result.png 
Size is 567, 479 
Coordinate System is `' 
Image Structure Metadata: 
    INTERLEAVE=PIXEL 
Corner Coordinates: 
Upper Left ( 0.0, 0.0) 
Lower Left ( 0.0, 479.0) 
Upper Right ( 567.0, 0.0) 
Lower Right ( 567.0, 479.0) 
Center  ( 283.5, 239.5) 
Band 1 Block=567x1 Type=Byte, ColorInterp=Red 
Band 2 Block=567x1 Type=Byte, ColorInterp=Green 
Band 3 Block=567x1 Type=Byte, ColorInterp=Blue 

Ancak, yalnızca PNG resimleri için çalıştığını -define option görünüyor.

Soruma Soru: JPG görüntüleri için aynı efekti nasıl elde edebilirim? Ben JPG için yukarıdaki komutu çalıştığınızda

, çalışmıyor:

convert image.jpg -define jpg:color-type=2 result.jpg 

gdalinfo [başarısız dönüştürülen JPG]:

Driver: JPEG/JPEG JFIF 
Files: result.jpg 
Size is 1500, 1061 
Coordinate System is `' 
Metadata: 
    EXIF_ColorSpace=1 
    EXIF_PixelYDimension=2480 
    ... 
    EXIF_YCbCrPositioning=1 
    EXIF_YResolution=(300) 
Corner Coordinates: 
Upper Left ( 0.0, 0.0) 
Lower Left ( 0.0, 1061.0) 
Upper Right (1500.0, 0.0) 
Lower Right (1500.0, 1061.0) 
Center  ( 750.0, 530.5) 
Band 1 Block=1500x1 Type=Byte, ColorInterp=Gray 
    Overviews: 750x531, 375x266, 188x133 
    Image Structure Metadata: 
    COMPRESSION=JPEG 

cevap

7

PNG renk çeşitleri JPEG için geçerli değildir görüntüleri, aynı tekniği kullanamazsınız.

convert input.jpg -colorspace sRGB -type truecolor result.jpg 
+0

sayesinde hızlı tepki için bir sürü: Bir palettised görüntü elde kalmamak sRGB'ye colorspace zorlayarak deneyin ve/veya TrueColour türünü ayarlama. Kayıt için: 'input input.jpg -tipi truecolor sonuç.jpg 'iyi çalıştı. -colorspace sRGB'yi eklerken aynı sonucu verdi, tek başına kullanarak işi bitiremedi. – NotYanka

İlgili konular