Skip to content

Image Processing Error: Quality values converted from integers to decimals #622

@fabidick22

Description

@fabidick22

Describe the bug
When creating a transformation policy through the Admin UI with quality output optimization using DPR mappings, the integer values (1-100) are being stored as decimal ratios (0-1) in DynamoDB, causing image processing failures.

The following error is being generated by the image processing service:

{
    "requestId": "24c6c8b9-d3f9-4084-aff0-8258492c6ec6",
    "component": "ImageRouter",
    "operation": "request_error",
    "duration": 142,
    "statusCode": 500,
    "errorType": "Image Processing Error",
    "clientMessage": "Image transformation failed",
    "originalError": "Expected integer between 1 and 100 for quality but received 0.85 of type number",
    "originalStack": "Error: Expected integer between 1 and 100 for quality but received 0.85 of type number\n    at Object.invalidParameterError (/app/node_modules/sharp/lib/is.js:135:10)\n    at Sharp.webp (/app/node_modules/sharp/lib/output.js:696:18)\n    at Sharp.toFormat (/app/node_modules/sharp/lib/output.js:459:28)\n    at EditApplicator.<anonymous> (/app/dist/container/src/services/image-processing/transformation-engine/edit-applicator.js:130:23)\n    at Generator.next (<anonymous>)\n    at fulfilled (/app/dist/container/src/services/image-processing/transformation-engine/edit-applicator.js:7:58)",
    "stack": "ImageProcessingError: Image transformation failed\n    at EditApplicator.<anonymous> (/app/dist/container/src/services/image-processing/transformation-engine/edit-applicator.js:71:23)\n    at Generator.throw (<anonymous>)\n    at rejected (/app/dist/container/src/services/image-processing/transformation-engine/edit-applicator.js:8:65)"
}

To Reproduce

  • Access the Admin UI and create a new transformation policy
  • Add a "Quality" output optimization
  • Configure DPR rules with integer quality values, for example:
    • Default quality: 75
    • DPR range 1-1.5: quality 60
    • DPR range 2+: quality 85
  • Save the policy
  • Make an image request that triggers the quality optimization
  • Check the service logs and DynamoDB table directly

Expected behavior
The policy should be stored in DynamoDB with integer quality values (1-100):

{
  "type": "quality",
  "value": [75, [1, 1.5, 60], [2, 999, 85]]
}

Actual Behavior:
The values are stored as decimal ratios (0-1):

{
  "type": "quality", 
  "value": [75, [1, 1.5, 0.6], [2, 999, 0.85]]
}

Please complete the following information about the solution:

  • Version: v8
  • Region: us-east-1
  • Was the solution modified from the version published on this repository? No
  • If the answer to the previous question was yes, are the changes available on GitHub?
  • Have you checked your service quotas for the sevices this solution uses?
  • Were there any errors in the CloudWatch Logs?

Screenshots
Web UI
Image

DynamoDB table
Image

Additional context

qualityConfig.push([minDpr, maxDpr, qualityValue / 100]); // Convert to 0-1 ratio

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions