Giter VIP home page Giter VIP logo

Comments (5)

jsummers avatar jsummers commented on July 17, 2024

Click "Network" to see my suggested fix for this ("improve-canvas-size") and other issues.

from resize.

 avatar commented on July 17, 2024

Hi Jason,

thank you for your reply. I switched to your branch to give it a try and I have to say you did amazing work, results are perfect. I can see only one problem. It seems that after resize there appears some kind of border when I use other filter than NearestNeighbor and save as JPG, why is it so and is it intent?

Saved as JPG:

Bicubic
Bicubic

Bilinear
Bilinear

Lanczos2
Lanczos2

Lanczos3
Lanczos3

NearestNeighbor
NearestNeighbor

MitchellNetravali
MitchellNetravali

When I save result image as PNG the resulting images are with some black parts:

Bicubic
Bicubic

Bilinear
Bilinear

Lanczos2
Lanczos2

Lanczos3
Lanczos3

MitchellNetravali
MitchellNetravali

NearestNeighbor
NearestNeighbor

from resize.

jsummers avatar jsummers commented on July 17, 2024

This isn't the appropriate place to suggest using fpresize instead (disclosure: I am the author), but GitHub doesn't have private messaging, and you have no contact info.

I don't know what the problem is with the PNG images. Looks like some sort of numeric overflow/underflow. I'll look into it when I get a chance.

The border around the JPEG images is there because nfnt/resize uses transparent virtual pixels. That's useful sometimes, but it's not good if you're going to write the image to a file format that does not support transparency.

Assuming the original image did not have any transparency, then stripping the alpha channel before writing the JPEG file is probably the best thing to do (i.e. set each pixel to have maximum opacity).

from resize.

jsummers avatar jsummers commented on July 17, 2024

The PNG corruption is caused by invalid combinations of color and transparency values. I fixed it in my copy of the project.

from resize.

nfnt avatar nfnt commented on July 17, 2024

Issue is fixed. I pulled in the fixes from Jason, thanks you!
FYI, the "black parts" issue was caused by the way Go's image packages handles accessing value outside the image boundaries. It returns constant zeros, also on the alpha channel, if the underlying image has one. I fixed it by replicating the first/last row/column values if accessing values outside the boundaries.

from resize.

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.