Skip to content
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

Merged
merged 2 commits into from
May 16, 2023

Conversation

Luftalian
Copy link
Member

背景を白色にするようにしました。
&image.Uniform{color.Transparent}で背景を透明にできるようにしようとしたのですが、うまくいかず背景が真っ黒になってしまったため、&image.Uniform{color.White}を使いました。
背景が透明なPNGを手元でアップロードしたら、背景が白くなることが確認できました。

@Luftalian Luftalian linked an issue Mar 17, 2023 that may be closed by this pull request
@H1rono H1rono requested a review from ryoha000 March 20, 2023 13:09
Copy link
Member

@ryoha000 ryoha000 left a 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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err は握りつぶさず 500 とかで返してほしいです

Comment on lines +55 to +56
draw.Draw(newImg, newImg.Bounds(), &image.Uniform{color.White}, image.Point{}, draw.Src)
draw.Draw(newImg, newImg.Bounds(), orig, orig.Bounds().Min, draw.Over)
Copy link
Member

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:(試してない)

Copy link
Member Author

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{}がうまく行かず

@Luftalian Luftalian requested a review from ryoha000 March 28, 2023 12:55
Copy link
Member

@ryoha000 ryoha000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ryoha000 ryoha000 merged commit 241a04e into master May 16, 2023
@ryoha000 ryoha000 deleted the black_background branch May 16, 2023 12:32
cp-20 added a commit that referenced this pull request Sep 30, 2023
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

画像アップロード時に透明な部分が黒くなる
2 participants