Giter VIP home page Giter VIP logo

Comments (8)

willnorris avatar willnorris commented on August 22, 2024

Thanks @dpup for your little gif-resize example! I reworked it into a reusable package (58bb2e4), and it works great.

Original blob image:

blob.gif
https://raw.githubusercontent.com/dpup/go-scratch/master/gif-resize/blob.gif

Resized to 200px and rotated 90 degrees:

blob.gif
https://willnorris.com/api/imageproxy/200,r90,sWepT40QjkBVuX3IDUy87z1xlXCnx5clAOcxnoVHMq30/https://raw.githubusercontent.com/dpup/go-scratch/master/gif-resize/blob.gif

from imageproxy.

dpup avatar dpup commented on August 22, 2024

Nice, glad it worked for you. In practice we have seen some issues with this approach on some gifs, and it will increase the size of the generated image.

from imageproxy.

willnorris avatar willnorris commented on August 22, 2024

Yeah, I noticed that some resized images were a bit larger than I would have expected. Did you come up with an alternative approach?

from imageproxy.

dpup avatar dpup commented on August 22, 2024

We just lived with it, but we have started transcoding gifs to video files,
for this and other reasons. I think the algorithm would be something like
this:

  1. check every pixel against the previous frame.
  2. if the color matches, make pixel transparent.
  3. set the frame bounds to be the smallest rectangle that covers
    non-transparent pixels.

On Sat, May 16, 2015, 9:52 PM Will Norris [email protected] wrote:

Yeah, I noticed that some resized images were a bit larger than I would
have expected. Did you come up with an alternative approach?


Reply to this email directly or view it on GitHub
#23 (comment)
.

from imageproxy.

willnorris avatar willnorris commented on August 22, 2024

@dpup: in case you're interested, I achieved considerable file size savings and reduced the noise simply by maintaining the original color palette. So from your source shapes.gif (377K):

Your original resized version is 1.7M:
shapes
https://raw.githubusercontent.com/dpup/go-scratch/master/gif-resize/shapes.out.fixed.gif

My updated version that maintains the original color palette is 223K:

shapes
https://willnorris.com/api/imageproxy/250,sdhIVIA2xBZJRhiNgO2CXxyT-iZF84WxUnJSRW8bq8CA/https://raw.githubusercontent.com/dpup/go-scratch/master/gif-resize/shapes.gif

from imageproxy.

dpup avatar dpup commented on August 22, 2024

That'll cause resizing artifacts. A pixel's color in the resultant image
will be averaged across multiple pixels in the source image, and the
average may not exist in the palette.

On Mon, May 18, 2015, 3:47 PM Will Norris [email protected] wrote:

@dpup https://github.com/dpup: in case you're interested, I achieved
considerable file size savings and reduced the noise simply by maintaining
the original color palette. So from your source shapes.gif
https://raw.githubusercontent.com/dpup/go-scratch/master/gif-resize/shapes.gif
(377K):

Your original resized version is 1.7M:
[image: shapes]
https://raw.githubusercontent.com/dpup/go-scratch/master/gif-resize/shapes.out.fixed.gif

https://raw.githubusercontent.com/dpup/go-scratch/master/gif-resize/shapes.out.fixed.gif

My updated version that maintains the original color palette
5e9ceea
is 223K:

[image: shapes]
https://camo.githubusercontent.com/b5de477c0e46918cf39dca607afdd0d150c1cf86/68747470733a2f2f77696c6c6e6f727269732e636f6d2f6170692f696d61676570726f78792f3235302c736468495649413278425a4a5268694e674f3243587879542d695a4638345778556e4a5352573862713843412f68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f647075702f676f2d736372617463682f6d61737465722f6769662d726573697a652f7368617065732e676966

https://willnorris.com/api/imageproxy/250,sdhIVIA2xBZJRhiNgO2CXxyT-iZF84WxUnJSRW8bq8CA/https://raw.githubusercontent.com/dpup/go-scratch/master/gif-resize/shapes.gif


Reply to this email directly or view it on GitHub
#23 (comment)
.

from imageproxy.

willnorris avatar willnorris commented on August 22, 2024

yeah, I did consider that. Though in practice (at least with images that have large swaths of solid colors like above), the result is still far better than the alternative. In any event, thanks again for publishing your original tool. I'll keep playing with a few different approaches (maybe try to compute a closer palette to take pixel merging into account), but I think this is a good 80% solution.

from imageproxy.

willnorris avatar willnorris commented on August 22, 2024

note for future me: go1.5 will expose frame disposal data, the global color palette, and the background color index (e6092d64)

from imageproxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.