Giter Club home page Giter Club logo

Comments (9)

oliver-moran avatar oliver-moran commented on June 22, 2024

@speediro - I'm not sure if I understand you correctly but does this answer your question:

When we were developing the rotate function there were two approaches:

  1. We could rotate and resize the image accordingly
  2. We could rotate the image but not resize it

The first approach is non-destructive: all of your original image is still visible but the dimensions of the image will stretch to accommodate the rotation.

The second approach is destructive: the width and height of the image will not have change but after rotation some of your image will outside of the image bounds.

The default behavior is 1. The way to call behavior 2 is to pass false as a second argument to the rotate method:

image.rotate( 13 ); // rotate by 13 degrees and resize accordingly
image.rotate( 13, false ); // rotate by 13 degrees don't resize

Does that answer your issue?

from jimp.

speediro avatar speediro commented on June 22, 2024

@oliver-moran - not really.
The examples I posted show the result I get when doing the first.
As you can see, it does not really keep everything of the image. It created a very high image yet rotates over the correct angle.
Can you try my code with the first image I posted?
You should get the second image...

from jimp.

oliver-moran avatar oliver-moran commented on June 22, 2024

OK. Sounds like a bug so.

I'll be able to test it (and probably fix it) tonight.

from jimp.

oliver-moran avatar oliver-moran commented on June 22, 2024

Fixed. Will do a release tonight with this fix. Thanks for spotting it.

from jimp.

oliver-moran avatar oliver-moran commented on June 22, 2024

This is published on NPM. Thanks for spotting it.

from jimp.

speediro avatar speediro commented on June 22, 2024

@oliver-moran, nice, looks like it behaves correctly now.And thanks for JIMP and the quick resolution.

from jimp.

speediro avatar speediro commented on June 22, 2024

@oliver-moran , might have found another issue with rotation...
Can you check the following test? Is it possible that there are remnants of the first blitting op?

var lenna = new Jimp("lenna.png", function (err) {
    if (err) throw err;
    this.crop(0,200,512,200).write("./output/lenna-cropped.png").rotate(33).write("./output/lenna-rotate-33.png")
});

---edit---
I think I found the issue... I changed (still new at git, is it a pull request I have to create?)

        var max = (this.bitmap.width > this.bitmap.height) ? this.bitmap.width : this.bitmap.height;
        this.resize(max, max);

to

        var max= Math.max(w,h,this.bitmap.width,this.bitmap.height)
        this.resize(max, max);

from jimp.

oliver-moran avatar oliver-moran commented on June 22, 2024

Nice! Yes, do a pull request and I'll pull it in.

from jimp.

oliver-moran avatar oliver-moran commented on June 22, 2024

The fix for this has been pulled in. Will appear in the next release. Thanks!

from jimp.

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.