Rotate is JPEG-only: PNG and WebP need a hard rotation to be supported
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 54/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- typescript
- 領域
- frontend
調査の方向性
lib/private/Image.php:413、lib/private/Preview/Image.php:42、lib/composables/useExportImage.ts から始め、特に 112 行目の jpegSource() と 235 行目のダウンスケールされた結果を確認してください。@nextcloud/image-editor の state.rotation、orientedSize()、ENC0DABLE フローを比較してください。完了条件は、エクスポートによってメタデータと寸法が保持される場合にのみ PNG の回転を利用可能にし、ダウンスケールされた出力を拒否し、エクスポート中も PNG メタデータを保持することです。
索引モデルが issue の本文から書いたものです。
説明
The rotate button being added for JPEG writes the Exif orientation tag: two bytes, no decode, no re-encode, nothing lost however many times it is pressed. PNG and WebP have no equivalent, so the button is hidden for them and those files cannot be rotated from the viewer at all.
Neither format carries an orientation the stack honours. lib/private/Image.php:413 in server returns -1 for anything that is not IMAGETYPE_JPEG, so fixOrientation() in lib/private/Preview/Image.php:42 never fires and previews would keep the old framing even if the file did carry a tag. PNG's eXIf chunk and WebP's EXIF chunk are both dead ends here.
The only route is a hard rotation: decode, turn the pixels, re-encode, upload. @nextcloud/image-editor already does exactly that (state.rotation, orientedSize(), ENCODABLE), so the work is not the rotation itself but deciding whether the result is worth writing.
I measured four 90° turns, decoding and re-encoding each time, on an 800x600 synthetic photo:
| format | PSNR after 4 turns, Chromium | Firefox | size after 1 turn |
|---|---|---|---|
| PNG | bit exact | bit exact | 292KB → 273KB |
| WebP, default quality | 40.4 dB | 43.0 dB | 14.4KB → 14.7KB |
| WebP, quality 1 | bit exact | bit exact | 14.4KB → 141KB |
PNG costs nothing in pixels. toBlob('image/webp', 1) turns out to be lossless in both engines, but a lossy source re-encoded that way grows 10x in Chromium and 3.4x in Firefox.
[!IMPORTANT]
The pixels are the easy part. What blocks PNG today is that the export drops metadata and can silently shrink the image.
jpegSource() (lib/composables/useExportImage.ts:112) returns null unless source and target are both JPEG, so carryMetadata never runs for a PNG: eXIf, ICC and text chunks are gone after a rotate. And the export is subject to the canvas cap, reporting downscaled at useExportImage.ts:235 when it had to work smaller. A rotate that quietly resizes someone's image is worse than no rotate.
So for PNG:
- carry PNG metadata through the export the way JPEG's is carried
- refuse the rotation, rather than writing it, when the export comes back
downscaled - then show the button for PNG
For WebP, a re-encode has to sniff the source first: RIFF VP8L means a lossless source that can be re-encoded losslessly at no cost, VP8 means a lossy one where the choice is generation loss or a 3-10x file. Worth doing only if someone asks for it.
GIF, BMP, ICO, SVG and the preview-backed mimes (HEIC, HEIF, TIFF) are out of scope: the editor cannot write any of them back in their own format.
- 主要言語
- TypeScript
- スター
- 2
- フォーク
- 1
- 平均マージ
- 19時間 47分
- マージ済み PR(30日)
- 78
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextcloud-libraries/nextcloud-viewer のほかの issue
-
type: tests
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
nextcloud-libraries/nextcloud-viewer#111 ·
メンテナーはふだん 1 日以内に返信
-
type: enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
nextcloud-libraries/nextcloud-viewer#110 ·
メンテナーはふだん 1 日以内に返信
-
type: enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
nextcloud-libraries/nextcloud-viewer#106 ·
メンテナーはふだん 1 日以内に返信
-
type: enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
nextcloud-libraries/nextcloud-viewer#105 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
AI assisted status: confirmed type: discussion
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
nextcloud-libraries/nextcloud-viewer#17 ·
メンテナーはふだん 1 日以内に返信
nextcloud-libraries/nextcloud-viewer の issue をすべて見る
似ている issue
-
Navbar avatar and name stay stale after saving profile changes対応中かも @alexechoi が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
marmelab/atomic-crm#416 ·
メンテナーはふだん 1 日以内に返信
-
feature-request
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
bluesky-social/social-app#12343 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
lucide-icons/lucide#5165 ·
メンテナーはふだん 1 日以内に返信
-
[Feature] Preferences - Keep the theme selection popover open after selection for quick previewオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
marktext/marktext#6033 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:desktop bug has repro platform:macos
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
anthropics/claude-code#107903 ·