fix(coding-agent): Fix EXIF orientation for JPEG and WebP images (#2105)

* fix(coding-agent): apply EXIF orientation correction during image convert and resize

* docs(coding-agent): add PR reference to changelog entry
This commit is contained in:
Melih Mucuk
2026-03-13 19:44:14 +03:00
committed by GitHub
parent bd2c3ab67e
commit 738319e465
4 changed files with 193 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import type { ImageContent } from "@mariozechner/pi-ai";
import { applyExifOrientation } from "./exif-orientation.js";
import { loadPhoton } from "./photon.js";
export interface ImageResizeOptions {
@@ -69,7 +70,10 @@ export async function resizeImage(img: ImageContent, options?: ImageResizeOption
let image: ReturnType<typeof photon.PhotonImage.new_from_byteslice> | undefined;
try {
image = photon.PhotonImage.new_from_byteslice(new Uint8Array(inputBuffer));
const inputBytes = new Uint8Array(inputBuffer);
const rawImage = photon.PhotonImage.new_from_byteslice(inputBytes);
image = applyExifOrientation(photon, rawImage, inputBytes);
if (image !== rawImage) rawImage.free();
const originalWidth = image.get_width();
const originalHeight = image.get_height();