TryGhost / TryGhost/SDK

[image-transform] Unable to define better image quality than default

Open
#442 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
134
Forks
87
Avg merge
12m
Merged PRs (30d)
25

Description

https://github.com/TryGhost/SDK/blob/ebc8a4418c349c9097aeeb35ced4e619ad888ae9/packages/image-transform/lib/transform.js#L102

you should allow to define image quality, sharp does have options.quality option, default is 80 and graphic blogs need maximum quality
https://sharp.pixelplumbing.com/api-output#parameters-7

https://ghost.org/docs/themes/assets/

// package.json

"config": {
    "image_sizes": {
        "xxs": {
            "width": 30,
            "quality": 100
        },
        "xs": {
            "width": 100,
            "quality": 100
        },
        "s": {
            "width": 300,
            "quality": 100
        },
        "m": {
            "width": 600,
            "quality": 100
        },
        "l": {
            "width": 1000,
            "quality": 100
        },
        "xl": {
            "width": 2000,
            "quality": 90
        }
    }
}

it looks like, that this simple option add will enable new quality option
...imageDimensionConfig

https://github.com/TryGhost/Ghost/blob/master/ghost/core/core/frontend/web/middleware/handle-image-sizes.js#L138

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/image-transform/lib/transform.js at line 102 and inspect how imageDimensionConfig is passed to the image transformation. Compare the available sharp quality option with the Ghost image_sizes configuration example and verify how quality values flow through the SDK. Done means callers can define per-size quality rather than always using sharp's default.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.