Giter Site home page Giter Site logo

resize image - scale about image-js HOT 5 CLOSED

image-js avatar image-js commented on June 15, 2024
resize image - scale

from image-js.

Comments (5)

lpatiny avatar lpatiny commented on June 15, 2024

Size could be given in percentage or pixels, the transform may be proportional or not
{width:'100%'}
{height:'100'} // means the height will be 100 pixels and it is a proportional transform
{width:'120%', height:100} : non proportional transform. The width will have 120% of the current size and the height, 100 pixels

from image-js.

targos avatar targos commented on June 15, 2024

#65

from image-js.

targos avatar targos commented on June 15, 2024
  • Shrinking
    • sampling (discard rows / columns)
    • average ?
    • ...
  • Enlarge
    • interpolation
    • ...

from image-js.

lpatiny avatar lpatiny commented on June 15, 2024

For sampling I think this should be the way to select:

An example

1 1 0 0 1

5 pts -> 2 pts

To calculate increment we remove one to the original size
increment : (5 - 1) / 2 = 2
First value -> increment / 2 = 1
Next value -> 1 + 2 = 3

Result : 1 0

5 pts -> 3 pts
increment : (5 - 1) / 3 = 1.33
First value -> increment / 2 = 0.66

Point 0 : 0.66 -> Math.round -> 1
Point 1 : 0.66 + 1.33 = 2
Point 2 : 0.66 + 2 * 1.33 = 3.33 -> Math.round -> 3

Result : 1 0 0

I have updated the code at:
http://codeshare.io/vKLaq

from image-js.

cballesteros avatar cballesteros commented on June 15, 2024

This is interesting:
Subsampling.pdf

from image-js.

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.