Format | Size |
---|---|
JPEG | 101Kb |
WebP | 66Kb |
AVIF | 33Kb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// isIllustration returns true if image is cartoon like, including | |
// icons, logos, illustrations. | |
// | |
// It returns false for banners, product images, photos. | |
// | |
// We use this function to decide on lossy or lossless conversion for PNG when converting | |
// to the next generation format. | |
// | |
// The initial idea is from here: https://legacy.imagemagick.org/Usage/compare/#type_reallife | |
func (p *ImageMagick) isIllustration(src *img.Image, info *img.Info) (bool, error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func isIllustration(img []byte) (bool, error) { | |
mw := imagick.NewMagickWand() | |
err := mw.ReadImageBlob(img) | |
if err != nil { | |
return false, err | |
} | |
colorsCnt, colors = mw.GetImageHistogram() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isIllustrationTests = []*testIsIllustration{ | |
{"illustration-1.png", true}, | |
{"illustration-2.png", true}, | |
{"illustration-3.png", true}, | |
{"logo-1.png", true}, | |
{"logo-2.png", true}, | |
{"banner-1.png", false}, | |
{"screenshot-1.png", false}, | |
{"photo-1.png", false}, | |
{"photo-2.png", false}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img src="https://pixboost.com/yoursite.com/hero-banner.jpeg?optimise?auth=your-api-key" | |
alt="Superhero rescues the World"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img src="/hero-banner.jpeg" alt="Superhero rescues the World"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<img src="img/supercar.jpeg" alt="Fast red car"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<picture> | |
<source srcset="supercar.avif" type="image/avif"> | |
<source srcset="supercar.webp" type="image/webp"> | |
<img src="supercar.jpeg" alt="Fast red car"/> | |
</picture> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://pixboost.com/api/2/img/https://s3-ap-southeast-2.amazonaws.com/bucket-with-images/image.png/optimise?auth=apikey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"AWS": "arn:aws:iam::<ACCOUNT_ID>:user/<USER_ID>" | |
}, | |
"Action": "s3:ListBucket", | |
"Resource": "arn:aws:s3:::<BUCKET_NAME>" |
NewerOlder