-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
透明な画像を上げると背景が黒くなる問題の修正 #532
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&image.Uniform{color.Transparent}で背景を透明にできるようにしようとした
これがうまくいかないのは変換先がjpegなので透明度のプロパティがないからですね
router/files.go
Outdated
b := &bytes.Buffer{} | ||
_ = imaging.Encode(b, imaging.Fit(orig, 360, 480, imaging.Linear), imaging.JPEG, imaging.JPEGQuality(85)) | ||
_ = imaging.Encode(b, imaging.Fit(newImg, 360, 480, imaging.Linear), imaging.JPEG, imaging.JPEGQuality(85)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err は握りつぶさず 500 とかで返してほしいです
draw.Draw(newImg, newImg.Bounds(), &image.Uniform{color.White}, image.Point{}, draw.Src) | ||
draw.Draw(newImg, newImg.Bounds(), orig, orig.Bounds().Min, draw.Over) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
draw.DrawMask(newImg, newImg.Bounds(), orig, image.Point{}, &draw.Op{draw.Src}, nil, &draw.SrcOver{})
とかでできそうな気配あるけどどうですか:eyes:(試してない)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&draw.Op{draw.Src}
と&draw.SrcOver{}
がうまく行かず
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Revert ":arrow_up: GitHub Actionsの依存 (#541)" This reverts commit e98d86b. Revert "Bump Golang from 1.15 to 1.20 (#540)" This reverts commit 60f9ccc. Revert "ポート番号の修正 (#534)" This reverts commit 3e00b30. Revert "透明な画像を上げると背景が黒くなる問題の修正 (#532)" This reverts commit 241a04e. Revert "Add default value (#535)" This reverts commit c56f2b4. Revert "validatorを追加 (#530)" This reverts commit 2b83f22. Revert "enumにした (#529)" This reverts commit 37e9d27. Revert "X-Showcase-User を debug 時無視するように (#531)" This reverts commit 6808496. Revert "GetItemResponseを追加 (#528)" This reverts commit d3e3d7e. Revert "air と dockerize をやめる (#527)" This reverts commit 2059554.
背景を白色にするようにしました。
&image.Uniform{color.Transparent}
で背景を透明にできるようにしようとしたのですが、うまくいかず背景が真っ黒になってしまったため、&image.Uniform{color.White}
を使いました。背景が透明なPNGを手元でアップロードしたら、背景が白くなることが確認できました。