Imagick composite produces a significantly larger output filesize

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
zanderwar
Posts: 3
Joined: 2019-01-17T21:06:43-07:00
Authentication code: 1152

Imagick composite produces a significantly larger output filesize

Post by zanderwar »

I've spent several hours trying to discover how after Imagick composes an image atop of another that `7.97KB + 98.39KB = 725.49KB`, when you'd expect 1/8th of that.

Code: Select all

$outputLocation = 'output.png';

$mask = new \Imagick('mask.png');
$overlay = new \Imagick('overlay.png');

$overlay->resizeImage(800, 600, \Imagick::FILTER_LANCZOS, 1);
$overlay->compositeImage($mask, \Imagick::COMPOSITE_COPYOPACITY, 0, 0, \Imagick::CHANNEL_ALPHA);

$overlay->writeImage($outputLocation );
$mask->destroy();
$overlay->destroy();

Does anyone have any idea how I can dramatically reduce the output size? As these images are intended for web and the input files are small, I was expecting around the 50KB-100KB mark or thereabouts.

Appreciate your time, thanks

Edit: I've added the output of `$imagick->identifyImage()` below each image and note that units become Pixels Per Centimeter when the input is "Undefined??" + "PPI". Not exactly sure what I'm looking at when I read 99% of it so hoping it helps with a solution
Mask: (7.97KB)
Image

Code: Select all

Image: /Uploads/5d28298a46/dm-full.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 800x600+0+0
  Units: Undefined
  Type: PaletteAlpha
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 8-bit
  Channel statistics:
    Pixels: 480000
    Red:
      min: 52 (0.203922)
      max: 255 (1)
      mean: 231.186 (0.90661)
      standard deviation: 65.3238 (0.256172)
      kurtosis: 3.65714
      skewness: -2.37848
      entropy: 0.521586
    Green:
      min: 52 (0.203922)
      max: 255 (1)
      mean: 231.186 (0.90661)
      standard deviation: 65.3238 (0.256172)
      kurtosis: 3.65714
      skewness: -2.37848
      entropy: 0.521586
    Blue:
      min: 49 (0.192157)
      max: 255 (1)
      mean: 230.834 (0.90523)
      standard deviation: 66.2892 (0.259958)
      kurtosis: 3.65714
      skewness: -2.37848
      entropy: 0.521586
    Alpha:
      min: 0 (0)
      max: 255 (1)
      mean: 29.7496 (0.116665)
      standard deviation: 81.772 (0.320674)
      kurtosis: 3.70517
      skewness: -2.38776
      entropy: 0.549454
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 229.614 (0.900446)
      standard deviation: 70.0274 (0.274617)
      kurtosis: 4.09826
      skewness: -2.44298
      entropy: 0.528553
  Alpha: srgba(255,255,255,0)   #FFFFFF00
  Colors: 132
  Histogram:
     55331: ( 52, 52, 49,255) #343431FF srgba(52,52,49,1)
        87: ( 52, 52, 49,254) #343431FE srgba(52,52,49,0.996078)
        47: ( 52, 52, 49,253) #343431FD srgba(52,52,49,0.992157)
        46: ( 52, 52, 49,252) #343431FC srgba(52,52,49,0.988235)
        27: ( 52, 52, 49, 12) #3434310C srgba(52,52,49,0.0470588)
        24: ( 52, 52, 49,248) #343431F8 srgba(52,52,49,0.972549)
        23: ( 52, 52, 49,249) #343431F9 srgba(52,52,49,0.976471)
        22: ( 52, 52, 49,251) #343431FB srgba(52,52,49,0.984314)
        18: ( 52, 52, 49,233) #343431E9 srgba(52,52,49,0.913725)
        17: ( 52, 52, 49,215) #343431D7 srgba(52,52,49,0.843137)
        17: ( 52, 52, 49, 34) #34343122 srgba(52,52,49,0.133333)
        16: ( 52, 52, 49,  8) #34343108 srgba(52,52,49,0.0313725)
        15: ( 52, 52, 49,  4) #34343104 srgba(52,52,49,0.0156863)
        14: ( 52, 52, 49,245) #343431F5 srgba(52,52,49,0.960784)
        13: ( 52, 52, 49,238) #343431EE srgba(52,52,49,0.933333)
        12: ( 52, 52, 49,236) #343431EC srgba(52,52,49,0.92549)
        12: ( 52, 52, 49,229) #343431E5 srgba(52,52,49,0.898039)
        12: ( 52, 52, 49, 48) #34343130 srgba(52,52,49,0.188235)
        12: ( 52, 52, 49, 38) #34343126 srgba(52,52,49,0.14902)
        11: ( 52, 52, 49,243) #343431F3 srgba(52,52,49,0.952941)
        11: ( 52, 52, 49,240) #343431F0 srgba(52,52,49,0.941176)
        11: ( 52, 52, 49,103) #34343167 srgba(52,52,49,0.403922)
        11: ( 52, 52, 49,100) #34343164 srgba(52,52,49,0.392157)
        10: ( 52, 52, 49,250) #343431FA srgba(52,52,49,0.980392)
        10: ( 52, 52, 49,246) #343431F6 srgba(52,52,49,0.964706)
        10: ( 52, 52, 49,178) #343431B2 srgba(52,52,49,0.698039)
        10: ( 52, 52, 49, 52) #34343134 srgba(52,52,49,0.203922)
         9: ( 52, 52, 49,247) #343431F7 srgba(52,52,49,0.968627)
         9: ( 52, 52, 49,202) #343431CA srgba(52,52,49,0.792157)
         9: ( 52, 52, 49, 71) #34343147 srgba(52,52,49,0.278431)
         9: ( 52, 52, 49, 20) #34343114 srgba(52,52,49,0.0784314)
         9: ( 52, 52, 49, 16) #34343110 srgba(52,52,49,0.0627451)
         8: ( 52, 52, 49,228) #343431E4 srgba(52,52,49,0.894118)
         8: ( 52, 52, 49,199) #343431C7 srgba(52,52,49,0.780392)
         8: ( 52, 52, 49,119) #34343177 srgba(52,52,49,0.466667)
         8: ( 52, 52, 49, 27) #3434311B srgba(52,52,49,0.105882)
         7: ( 52, 52, 49,241) #343431F1 srgba(52,52,49,0.945098)
         7: ( 52, 52, 49,230) #343431E6 srgba(52,52,49,0.901961)
         7: ( 52, 52, 49,220) #343431DC srgba(52,52,49,0.862745)
         7: ( 52, 52, 49,209) #343431D1 srgba(52,52,49,0.819608)
         7: ( 52, 52, 49,194) #343431C2 srgba(52,52,49,0.760784)
         7: ( 52, 52, 49,173) #343431AD srgba(52,52,49,0.678431)
         7: ( 52, 52, 49,162) #343431A2 srgba(52,52,49,0.635294)
         7: ( 52, 52, 49,156) #3434319C srgba(52,52,49,0.611765)
         7: ( 52, 52, 49,134) #34343186 srgba(52,52,49,0.52549)
         7: ( 52, 52, 49, 89) #34343159 srgba(52,52,49,0.34902)
         7: ( 52, 52, 49, 30) #3434311E srgba(52,52,49,0.117647)
         6: ( 52, 52, 49,237) #343431ED srgba(52,52,49,0.929412)
         6: ( 52, 52, 49,227) #343431E3 srgba(52,52,49,0.890196)
         6: ( 52, 52, 49,186) #343431BA srgba(52,52,49,0.729412)
         6: ( 52, 52, 49,176) #343431B0 srgba(52,52,49,0.690196)
         6: ( 52, 52, 49,169) #343431A9 srgba(52,52,49,0.662745)
         6: ( 52, 52, 49,128) #34343180 srgba(52,52,49,0.501961)
         6: ( 52, 52, 49,126) #3434317E srgba(52,52,49,0.494118)
         6: ( 52, 52, 49,114) #34343172 srgba(52,52,49,0.447059)
         6: ( 52, 52, 49,105) #34343169 srgba(52,52,49,0.411765)
         6: ( 52, 52, 49, 98) #34343162 srgba(52,52,49,0.384314)
         6: ( 52, 52, 49, 65) #34343141 srgba(52,52,49,0.254902)
         5: ( 52, 52, 49,242) #343431F2 srgba(52,52,49,0.94902)
         5: ( 52, 52, 49,225) #343431E1 srgba(52,52,49,0.882353)
         5: ( 52, 52, 49,218) #343431DA srgba(52,52,49,0.854902)
         5: ( 52, 52, 49,148) #34343194 srgba(52,52,49,0.580392)
         5: ( 52, 52, 49,140) #3434318C srgba(52,52,49,0.54902)
         5: ( 52, 52, 49,131) #34343183 srgba(52,52,49,0.513725)
         5: ( 52, 52, 49,124) #3434317C srgba(52,52,49,0.486275)
         5: ( 52, 52, 49,117) #34343175 srgba(52,52,49,0.458824)
         5: ( 52, 52, 49, 44) #3434312C srgba(52,52,49,0.172549)
         4: ( 52, 52, 49,234) #343431EA srgba(52,52,49,0.917647)
         4: ( 52, 52, 49,226) #343431E2 srgba(52,52,49,0.886275)
         4: ( 52, 52, 49,224) #343431E0 srgba(52,52,49,0.878431)
         4: ( 52, 52, 49,223) #343431DF srgba(52,52,49,0.87451)
         4: ( 52, 52, 49,217) #343431D9 srgba(52,52,49,0.85098)
         4: ( 52, 52, 49,214) #343431D6 srgba(52,52,49,0.839216)
         4: ( 52, 52, 49,213) #343431D5 srgba(52,52,49,0.835294)
         4: ( 52, 52, 49,206) #343431CE srgba(52,52,49,0.807843)
         4: ( 52, 52, 49,203) #343431CB srgba(52,52,49,0.796078)
         4: ( 52, 52, 49,200) #343431C8 srgba(52,52,49,0.784314)
         4: ( 52, 52, 49,188) #343431BC srgba(52,52,49,0.737255)
         4: ( 52, 52, 49,182) #343431B6 srgba(52,52,49,0.713725)
         4: ( 52, 52, 49,180) #343431B4 srgba(52,52,49,0.705882)
         4: ( 52, 52, 49,168) #343431A8 srgba(52,52,49,0.658824)
         4: ( 52, 52, 49,165) #343431A5 srgba(52,52,49,0.647059)
         4: ( 52, 52, 49,154) #3434319A srgba(52,52,49,0.603922)
         4: ( 52, 52, 49,145) #34343191 srgba(52,52,49,0.568627)
         4: ( 52, 52, 49,111) #3434316F srgba(52,52,49,0.435294)
         4: ( 52, 52, 49,109) #3434316D srgba(52,52,49,0.427451)
         4: ( 52, 52, 49, 92) #3434315C srgba(52,52,49,0.360784)
         4: ( 52, 52, 49, 84) #34343154 srgba(52,52,49,0.329412)
         4: ( 52, 52, 49, 80) #34343150 srgba(52,52,49,0.313725)
         4: ( 52, 52, 49, 77) #3434314D srgba(52,52,49,0.301961)
         4: ( 52, 52, 49, 74) #3434314A srgba(52,52,49,0.290196)
         4: ( 52, 52, 49, 68) #34343144 srgba(52,52,49,0.266667)
         4: ( 52, 52, 49, 42) #3434312A srgba(52,52,49,0.164706)
         4: ( 52, 52, 49, 24) #34343118 srgba(52,52,49,0.0941176)
         3: ( 52, 52, 49,239) #343431EF srgba(52,52,49,0.937255)
         3: ( 52, 52, 49,235) #343431EB srgba(52,52,49,0.921569)
         3: ( 52, 52, 49,231) #343431E7 srgba(52,52,49,0.905882)
         3: ( 52, 52, 49,216) #343431D8 srgba(52,52,49,0.847059)
         3: ( 52, 52, 49,210) #343431D2 srgba(52,52,49,0.823529)
         3: ( 52, 52, 49,207) #343431CF srgba(52,52,49,0.811765)
         3: ( 52, 52, 49,197) #343431C5 srgba(52,52,49,0.772549)
         3: ( 52, 52, 49,196) #343431C4 srgba(52,52,49,0.768627)
         3: ( 52, 52, 49,185) #343431B9 srgba(52,52,49,0.72549)
         3: ( 52, 52, 49,171) #343431AB srgba(52,52,49,0.670588)
         3: ( 52, 52, 49,166) #343431A6 srgba(52,52,49,0.65098)
         3: ( 52, 52, 49,152) #34343198 srgba(52,52,49,0.596078)
         3: ( 52, 52, 49,142) #3434318E srgba(52,52,49,0.556863)
         3: ( 52, 52, 49,135) #34343187 srgba(52,52,49,0.529412)
         3: ( 52, 52, 49,121) #34343179 srgba(52,52,49,0.47451)
         3: ( 52, 52, 49, 86) #34343156 srgba(52,52,49,0.337255)
         3: ( 52, 52, 49, 62) #3434313E srgba(52,52,49,0.243137)
         3: ( 52, 52, 49, 58) #3434313A srgba(52,52,49,0.227451)
         2: ( 52, 52, 49,244) #343431F4 srgba(52,52,49,0.956863)
         2: ( 52, 52, 49,232) #343431E8 srgba(52,52,49,0.909804)
         2: ( 52, 52, 49,222) #343431DE srgba(52,52,49,0.870588)
         2: ( 52, 52, 49,221) #343431DD srgba(52,52,49,0.866667)
         2: ( 52, 52, 49,211) #343431D3 srgba(52,52,49,0.827451)
         2: ( 52, 52, 49,201) #343431C9 srgba(52,52,49,0.788235)
         2: ( 52, 52, 49,193) #343431C1 srgba(52,52,49,0.756863)
         2: ( 52, 52, 49,191) #343431BF srgba(52,52,49,0.74902)
         2: ( 52, 52, 49,183) #343431B7 srgba(52,52,49,0.717647)
         2: ( 52, 52, 49,175) #343431AF srgba(52,52,49,0.686275)
         2: ( 52, 52, 49,161) #343431A1 srgba(52,52,49,0.631373)
         2: ( 52, 52, 49,159) #3434319F srgba(52,52,49,0.623529)
         2: ( 52, 52, 49,147) #34343193 srgba(52,52,49,0.576471)
         2: ( 52, 52, 49,138) #3434318A srgba(52,52,49,0.541176)
         2: ( 52, 52, 49, 55) #34343137 srgba(52,52,49,0.215686)
         1: ( 52, 52, 49,205) #343431CD srgba(52,52,49,0.803922)
         1: ( 52, 52, 49,190) #343431BE srgba(52,52,49,0.745098)
         1: ( 52, 52, 49,151) #34343197 srgba(52,52,49,0.592157)
         1: ( 52, 52, 49, 95) #3434315F srgba(52,52,49,0.372549)
    423690: (255,255,255,  0) #FFFFFF00 srgba(255,255,255,0)
  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)
  Background color: white
  Border color: srgba(223,223,223,1)
  Matte color: grey74
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 800x600+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Properties:
    date:create: 2019-01-17T17:28:42-07:00
    date:modify: 2019-01-17T17:28:42-07:00
    png:IHDR.bit-depth-orig: 8
    png:IHDR.bit_depth: 8
    png:IHDR.color-type-orig: 6
    png:IHDR.color_type: 6 (RGBA)
    png:IHDR.interlace_method: 0 (Not interlaced)
    png:IHDR.width,height: 800, 600
    png:sRGB: intent=0 (Perceptual Intent)
    png:text: 1 tEXt/zTXt/iTXt chunks were found
    signature: 66726c0234cca3a421acd3f8b0a26bb208aa027de7e96f629ab886f9811e8ba2
    Software: Adobe ImageReady
  Tainted: False
  Filesize: 7.97KB
  Number pixels: 480K
  Pixels per second: 9.6MB
  User time: 0.040u
  Elapsed time: 0:01.049
  Version: ImageMagick 6.9.4-10 Q16 x86_64 2017-11-14 http://www.imagemagick.org
Overlay: (98.39KB)
Image

Code: Select all

Image: /Uploads/66e0704554/rip1.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 640x480+0+0
  Resolution: 96x96
  Print size: 6.66667x5
  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: 307200
    Red:
      min: 59 (0.231373)
      max: 241 (0.945098)
      mean: 138.879 (0.544625)
      standard deviation: 43.3873 (0.170146)
      kurtosis: -1.00018
      skewness: 0.474575
      entropy: 0.959705
    Green:
      min: 56 (0.219608)
      max: 223 (0.87451)
      mean: 133.056 (0.521788)
      standard deviation: 38.0973 (0.149401)
      kurtosis: -0.944014
      skewness: 0.443263
      entropy: 0.958768
    Blue:
      min: 57 (0.223529)
      max: 213 (0.835294)
      mean: 128.22 (0.502823)
      standard deviation: 34.149 (0.133917)
      kurtosis: -0.889802
      skewness: 0.384749
      entropy: 0.95673
  Image statistics:
    Overall:
      min: 56 (0.219608)
      max: 241 (0.945098)
      mean: 133.385 (0.523079)
      standard deviation: 38.7299 (0.151882)
      kurtosis: -0.730287
      skewness: 0.517232
      entropy: 0.958401
  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)
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 640x480+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 90
  Orientation: Undefined
  Properties:
    comment: CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 90

    date:create: 2019-01-17T18:51:23-07:00
    date:modify: 2019-01-17T07:02:14-07:00
    jpeg:colorspace: 2
    jpeg:sampling-factor: 1x1,1x1,1x1
    signature: 18b3909f043cc43ed544dc1186c2bf12e82d754b25ce79d9f751711bca0bb9e5
  Tainted: False
  Filesize: 98.4KB
  Number pixels: 307K
  Pixels per second: 30.72MB
  User time: 0.010u
  Elapsed time: 0:01.009
  Version: ImageMagick 6.9.4-10 Q16 x86_64 2017-11-14 http://www.imagemagick.org
Output: **(725.49KB!!)**
Image

Code: Select all

Image: /Uploads/full-vest-ucp-digital-camouflage-ripstop.png
  Format: PNG (Portable Network Graphics)
  Mime type: image/png
  Class: DirectClass
  Geometry: 800x600+0+0
  Resolution: 37.79x37.79
  Print size: 21.1696x15.8772
  Units: PixelsPerCentimeter
  Type: TrueColorAlpha
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 8-bit
  Channel statistics:
    Pixels: 480000
    Red:
      min: 59 (0.231373)
      max: 242 (0.94902)
      mean: 138.88 (0.544628)
      standard deviation: 43.3913 (0.170162)
      kurtosis: -1.0001
      skewness: 0.474861
      entropy: 0.959552
    Green:
      min: 57 (0.223529)
      max: 222 (0.870588)
      mean: 133.055 (0.521786)
      standard deviation: 38.1002 (0.149413)
      kurtosis: -0.94345
      skewness: 0.443572
      entropy: 0.958694
    Blue:
      min: 57 (0.223529)
      max: 213 (0.835294)
      mean: 128.22 (0.502822)
      standard deviation: 34.1488 (0.133917)
      kurtosis: -0.88896
      skewness: 0.385181
      entropy: 0.956701
    Alpha:
      min: 0 (0)
      max: 255 (1)
      mean: 29.7496 (0.116665)
      standard deviation: 81.772 (0.320674)
      kurtosis: 3.70517
      skewness: -2.38776
      entropy: 0.0731075
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 156.351 (0.613143)
      standard deviation: 52.8848 (0.207392)
      kurtosis: 2.60166
      skewness: 0.242498
      entropy: 0.737014
  Alpha: srgba(139,135,130,0)   #8B878200
  Rendering intent: Perceptual
  Gamma: 0.45455
  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)
  Background color: white
  Border color: srgba(223,223,223,1)
  Matte color: grey74
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 800x600+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Properties:
    comment: CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 90

    date:create: 2019-01-17T21:30:04-07:00
    date:modify: 2019-01-17T21:30:04-07:00
    png:bKGD: chunk was found (see Background color, above)
    png:cHRM: chunk was found (see Chromaticity, above)
    png:gAMA: gamma=0.45454544 (See Gamma, above)
    png:IHDR.bit-depth-orig: 8
    png:IHDR.bit_depth: 8
    png:IHDR.color-type-orig: 6
    png:IHDR.color_type: 6 (RGBA)
    png:IHDR.interlace_method: 0 (Not interlaced)
    png:IHDR.width,height: 800, 600
    png:pHYs: x_res=3779, y_res=3779, units=1
    png:sRGB: intent=0 (Perceptual Intent)
    png:text: 3 tEXt/zTXt/iTXt chunks were found
    png:tIME: 2019-01-17T07:02:14Z
    signature: 9466b41c1f7bea9638e3cda09749e796df0f594fbf5b152060e2ecd671ef80fd
  Tainted: False
  Filesize: 725KB
  Number pixels: 480K
  Pixels per second: 24MB
  User time: 0.030u
  Elapsed time: 0:01.019
  Version: ImageMagick 6.9.4-10 Q16 x86_64 2017-11-14 http://www.imagemagick.org
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imagick composite produces a significantly larger output filesize

Post by fmw42 »

You have converted from palette alpha to tricolor alpha. The latter is 32-bit, while the former is 8-bit. If you want to reduce size, then add PNG8: to your result to get palette alpha as the output.

Code: Select all

$outputLocation = 'PNG8:output.png'
zanderwar
Posts: 3
Joined: 2019-01-17T21:06:43-07:00
Authentication code: 1152

Re: Imagick composite produces a significantly larger output filesize

Post by zanderwar »

fmw42 wrote: 2019-01-17T23:04:24-07:00 You have converted from palette alpha to tricolor alpha. The latter is 32-bit, while the former is 8-bit. If you want to reduce size, then add PNG8: to your result to get palette alpha as the output.

Code: Select all

$outputLocation = 'PNG8:output.png'
Thank you very much, this got it down to 23.33K, however the output is quite grainy/speckles as per below, any idea on how to improve that?

Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Imagick composite produces a significantly larger output filesize

Post by snibgo »

Your text says "composes an image atop of another" but your code says you use CopyOpacity, not Atop.

The overlay you show is JPG, not PNG.

Changing fully-transparent pixels to fully-transparent black makes a big difference to the size, and no visible difference to the result:

Code: Select all

magick 3p3F9Ir.jpg -resize 800x600 VJlPtvb.png -compose CopyOpacity -composite -background Black -alpha background x.png
snibgo's IM pages: im.snibgo.com
zanderwar
Posts: 3
Joined: 2019-01-17T21:06:43-07:00
Authentication code: 1152

Re: Imagick composite produces a significantly larger output filesize

Post by zanderwar »

Thanks guys, turns out PNG32 was fine after some posterization and despeckling. Sitting on 124KB after using a HD flower for testing purposes.

Image
Post Reply