Giter Club home page Giter Club logo

imazen / imageflow Goto Github PK

View Code? Open in Web Editor NEW
4.1K 67.0 137.0 7.54 MB

High-performance image manipulation for web servers. Includes imageflow_server, imageflow_tool, and libimageflow

Home Page: https://docs.imageflow.io/

License: GNU Affero General Public License v3.0

Ruby 0.29% C 17.16% C++ 25.84% Shell 3.29% Rust 51.87% HTML 0.04% JavaScript 0.10% Batchfile 0.05% Lua 0.57% CMake 0.17% Dockerfile 0.53% SWIG 0.03% Smarty 0.06%
image-server image-compression imagemagick image-manipulation tool lib

imageflow's Issues

Research photograph analysis techniques for determining the best compression parameters

It seems like decent heuristics for determining the ideal image format should exist.

Here's a theoretical one:

  1. If multi-frame, -> GIF
  2. If the alpha channel is actually in use, -> PNG
  3. No? Why not try to compress a few randomly distributed scanlines with DEFLATE. If the ratio sucks, use JPEG, otherwise use PNG.

Ok, using GIF? We need to decide the color table size, and whether to preserve transparency or support animation. We may consult the original GIF, and look at the operation graph to prove that no new colors were introduced, then re-use that table.

Using PNG? Oh, so many knobs and settings. 8-bit? 24-bit? 32-bit? Size of the color table?

JPEG? What subsampling format? What quality? Should quality decrease with resolution at a certain point (higher res usually means smaller pixels are being displayed)? Should we use trellis?

@pornel, I imagine you've thought about this quite a bit. Other than exhaustive attempts, are you aware of any good techniques for "doing the right thing" by default for the unopinionated user? We would want to budget <50ms for this, preferably <5ms for small images.

Question: how does an "insecure" library become "secure"?

Hi Nathanael, I was alerted to this rather interesting repo via your recent questions about libjpeg-turbo.

One thing that caught my eye was the statement in the readme about "trusted data":

"...all the libraries that I've reviewed are insecure. Some assume all images are trusted data (libvips)..."

libvips relies on the "standard" image decoding libraries such as libjpeg-turbo, libpng etc., most of which have seen the recent attention of fuzzing tools such as AFL.

Are you able to explain a little more about what is meant by "insecure" and "trusted data" in this context? What would you expect libraries to be doing in order to become "secure"?

My best guess is that this might relate to "trusted metadata", where fake headers could result in large memory allocations, assuming that data was able to get through the decoding library's own checks first.

Cheers,
Lovell

/cc @jcupitt

Draft operations-graph based framework

V4 cannot make the jump, as we want to retain backwards compatibility as much as possible with V3 - but we can start using it internally, perhaps.

Given image characteristics, we can translate descriptive URL commands into a graph (usually just a linked list) of operation placeholders.

Pipelines can report their support level for the given operation graph.

The abstract graph is converted to implementations.

And executed.

In theory this should let us perform a much wider range of optimizations (and enable better plugin support). By adding converters between implementations of non-compatible pipelines, we will also greatly extend the available abilities (being a super-set, not a subset of any leveraged dependency).

Add full graph validation

  • Ensure graph is acyclic
  • Ensure nodes and edges are not orphaned
  • Ensure node def constraints are upheld

Add subpixel cropping to compensate for block scaling

Block scaling in the decoder can leave edge pixels over-emphasized.
I.e, scale 9x9 image down to 25% - that's 3x3, not 2x2. But the bottom and right row of pixels have actually not been scaled at all! Unless they are weighted in a later scaling, they will remain an artefact.

Implement string error messages

We can use a hash function to generate the error code.
Static strings are easy, but what if we want to include debug info?
That's only possible when there is enough memory, so it needs to be able to fall back to just static numbers.

Notes for animated GIF support

  • One must loop through all frames and expand the 'screen size' to (left + width), (top + height) for each frame. Negative left/top coordinate handling unexplored.
  • Perhaps we should quantize in linear light?
  • Global color map optimization seems challenging

Add BitmapBgra reuse constraints

Verify that if more than one outbound edge exists for a node, that neither of those nodes mutate the bitmap. Either insert a Clone, or fail the graph.

Add halving optimizations

Render1D should expand into a HalveHorizontal and Render1D when there is a huge downsampling factor.

HalveHorizontal and HalveVerticle can be shifted left until they meet, then combined into a Halve2D. Halve2D can be shifted left to the decoder (if the decoder supports built-in scaling).

The job will have to represent some optimization rules, such as permitting perceptual scaling instead of linear scaling for the first 1/3rd of the job, or halving prior to colorspace application.

Decide how to expose animated gif type selection

For filesize, one wants to use delta-encoding for image frames (do not dispose (dispose=1)).
For transparency support, (restore to background (dispose=2)) needs to be used.

(do not dispose) may have transparent pixels, but intermediate frames could hide these.

Perhaps the default if any transparency is detected should be (restore to background), but let users override with &force_gif_delta?

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.