Rua Tahi
Rua Tahi

Reputation: 258

How to convert a TIFF to a JPG with ImageMagick?

Please help me. I need help to convert a TIFF file to JPG file, I do this with command line and ImageMagick from Ubuntu, like this

convert 03.tif 03.jpg

But my JPG file after convert like this enter image description here

I checked identify TIF file

$ magick identify -verbose 03.tif
Image:
  Filename: 03.tif
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 3507x2480+0+0
  Resolution: 299.999x299.999
  Print size: 11.69x8.26669
  Units: PixelsPerInch
  Colorspace: sRGB
  Type: PaletteAlpha
  Base type: TrueColor
  Endianness: LSB
  Depth: 8/4-bit
  Channel depth:
    Red: 4-bit
    Green: 1-bit
    Blue: 1-bit
    Alpha: 1-bit
  Channel statistics:
    Pixels: 8697360
    Red:
      min: 0  (0)
      max: 255 (1)
      mean: 246.36 (0.966117)
      median: 255 (1)
      standard deviation: 39.0814 (0.153261)
      kurtosis: 19.4019
      skewness: -4.56442
      entropy: 0.125155
    Green:
      min: 0  (0)
      max: 0 (0)
      mean: 0 (0)
      median: 0 (0)
      standard deviation: 0 (0)
      kurtosis: -3
      skewness: 0
      entropy: 0
    Blue:
      min: 0  (0)
      max: 0 (0)
      mean: 0 (0)
      median: 0 (0)
      standard deviation: 0 (0)
      kurtosis: -3
      skewness: 0
      entropy: 0
    Alpha:
      min: 255  (1)
      max: 255 (1)
      mean: 255 (1)
      median: 255 (1)
      standard deviation: -nan (-nan)
      kurtosis: -2.57089e+58
      skewness: 1.58031e+41
      entropy: 0

I want to convert TIF to JPG file this like original TIF file.

Upvotes: 3

Views: 4945

Answers (1)

Rua Tahi
Rua Tahi

Reputation: 258

I user docker and build image FROM php:7.3-fpm-alpine. I try to add imagemagick lib, but lastest version for 7.3-fpm-alpine is 7.0.10-48. like this

FROM php:7.3-fpm-alpine
RUN apk add --no-cache --virtual .build-deps \
    $PHPIZE_DEPS \
    curl-dev \
    imagemagick-dev \
    libtool \
    libxml2-dev \
    postgresql-dev \
    sqlite-dev \
&& apk add --no-cache \
    curl \
    git \
    imagemagick \
    mysql-client \
    postgresql-libs \
    libintl \
    icu \
    icu-dev \
    libzip-dev \
    freetype \
    libpng \
    libjpeg-turbo \
    freetype-dev \
    libpng-dev \
    libjpeg-turbo-dev \
    supervisor \
&& pecl install imagick \
&& docker-php-ext-enable imagick \

To resolve that problem, I change php:7.3-fpm-alpine to php:7.3.27-fpm-alpine3.13 And rebuild my container. It work for me. Thanks Mark Setchell for supporting.

Upvotes: 1

Related Questions