# Requisite sharp features/API to enable configurable image compression?

**URL:** <https://forum.ghost.org/t/requisite-sharp-features-api-to-enable-configurable-image-compression/26612>\
**Category:** Developer help\
**Created:** [November 1, 2021, 8:18am UTC](https://forum.ghost.org/t/requisite-sharp-features-api-to-enable-configurable-image-compression/26612 "2021-11-01T08:18:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dopplerfto](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@dopplerfto](https://forum.ghost.org/u/dopplerfto)\
**Post date:** [November 1, 2021, 8:18am UTC](https://forum.ghost.org/t/requisite-sharp-features-api-to-enable-configurable-image-compression/26612/1 "2021-11-01T08:18:51Z")

</div>

I was writing a new post on my photo blog when I discovered that my images look like trash once I open the preview in another window. That’s when I discovered

> [@Image Compression Configuration](https://forum.ghost.org/t/image-compression-configuration/13545):
>
> Hi gang! I’m setting up my first ghost site, and I really like it so far! This is my site: [https://121gigawatts.org](https://121gigawatts.org) One issue I ran into, and which has already been asked [once](https://forum.ghost.org/t/ghost-trial-image-compression/9266) or [twice](https://forum.ghost.org/t/hosted-ghost-image-compression/6874) on this forum, is how to configure image compression. I’m unhappy with the JPEG pixelated artifacts on my hero banner particularly on the “GIGAWATTS” font. The original actually has a rather homogenous colour, there’s no texture to it: Original: I’ve seen you guys raise this issue alr…

and consequently

> <https://github.com/lovell/sharp/issues/1360>
>
> When reading and jpeg image from file and writing it back to a different file wi…thout applying any transformations it loses size. Example:
> \`\`\`
> sharp('original.jpg').withMetadata().toFile('transformed.jpg');
> \`\`\`
> During the tranformation output is following:
> \`\`\`
> vips warning: exif: bad exif meta "exif-ifd3-GPSVersionID"
> \`\`\`
> 
> The version or sharp that is being used: \`v0.20.7\`
> \`file\` output:
> \`\`\`
> file \*.jpg
> original.jpg: JPEG image data, Exif standard: \[TIFF image data, big-endian, direntries=16, height=3968, bps=0, width=2976\], baseline, precision 8, 2976x3968, frames 3
> transformed.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, Exif Standard: \[TIFF image data, big-endian, direntries=15, height=3968, bps=0, width=2976\], baseline, precision 8, 2976x3968, frames 3
> \`\`\`
> 
> The image that is being transformed \`original.jpg\`:
> !\[original\](https://user-images.githubusercontent.com/675397/44801874-8cd77f80-abba-11e8-9782-fbfcb10be2e9.jpg)
> Transformed image \`transformed.jpg\`:
> !\[transformed\](https://user-images.githubusercontent.com/675397/44801882-982aab00-abba-11e8-90c0-f9ee92f3c7ab.jpg)
> Node versoin: \`v8.11.4\`
> OS: \`Ubuntu 18.04\`
> 
> Is this an expected behavior? What options could be specified to avoid any transformatios but still use sharp for writing the output file (this is needed due to specifics of wrapper library implementation)?

And I see that Ghost doesn’t have any codepaths to use other-than-default compression/quality right now:

> <https://github.com/TryGhost/Utils/blob/ba37890be49efc59381b17b9c78e0c9e2ed92eaf/packages/image-transform/lib/transform.js#L58>

I don’t want my images to look like trash (and I also don’t want to force my readers to download PNGs instead of a more reasonable format). So **what kind of API would need to exist in order for Ghost to provide some configurability here?** Just “default” / “better” / “best”? Something else? Would there be a desire to support even more aggressive compression than the default?

---

<div class="post-metadata">

**Author:** ![John](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/john/32/29288_2.png) [@John](https://forum.ghost.org/u/John)\
**Post date:** [November 1, 2021, 4:48pm UTC](https://forum.ghost.org/t/requisite-sharp-features-api-to-enable-configurable-image-compression/26612/2 "2021-11-01T16:48:18Z")

</div>

Compression and optimisation config is documented here.

> **[Configuration - Adapt your publication to suit your needs](https://ghost.org/docs/config/#compress)**
>
> Find out how to configure your Ghost publication or override Ghost's default behaviour with robust config options, including mail, storage, scheduling and more!

If you’re not satisfied with those options you can configure an external storage adapter, such as cloudinary, to host and optimise media externally to Ghost

> **[Configuration - Adapt your publication to suit your needs](https://ghost.org/docs/config/#available-custom-storage-adapters)**
>
> Find out how to configure your Ghost publication or override Ghost's default behaviour with robust config options, including mail, storage, scheduling and more!

---

<div class="post-metadata">

**Author:** ![piratefache](https://avatars.discourse-cdn.com/v4/letter/p/c4cdca/32.png) [@piratefache](https://forum.ghost.org/u/piratefache)\
**Post date:** [May 7, 2022, 9:20pm UTC](https://forum.ghost.org/t/requisite-sharp-features-api-to-enable-configurable-image-compression/26612/3 "2022-05-07T21:20:12Z")

</div>

Any news? @John the compression/quality feature is not in the documentation because it has not been implemented yet.

The default quality for JPEG files is 80% which is way too low for me. It has been a while now and I don’t see any other possibility than uploading png files images in order to preserve the image quality…

Did you plan to add this option soon ?

---

<div class="post-metadata">

**Author:** ![John](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/john/32/29288_2.png) [@John](https://forum.ghost.org/u/John)\
**Post date:** [May 9, 2022, 3:43pm UTC](https://forum.ghost.org/t/requisite-sharp-features-api-to-enable-configurable-image-compression/26612/4 "2022-05-09T15:43:51Z")

</div>

From the link directly above:

 ![CleanShot 2022-05-09 at 12.27.44@2x](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/3X/0/7/07ad7cd2baa31b6cd8a66ffac6640ac4d7d86d91.jpeg)
