Giter VIP home page Giter VIP logo

Comments (7)

toy avatar toy commented on May 28, 2024

You are welcome!

Processing of images as data is already there. You've guessed method name optimize_image_data correctly, also there is optimize_images_data. I just forgot to mention it in readme … already fixed.

from image_optim.

ippa avatar ippa commented on May 28, 2024

oh, heh, funny :). Now I've replaced:

io = IO.popen("/usr/bin/jpegtran -optimize /proc/self/fd/0", "r+").binmode
io.syswrite thumbnail.to_blob
io.flush
io.close_write
optimized_thumbnail = io.read
io.close_read

With:
optimized_thumbnail = @image_optim.optimize_image_data(thumbnail.to_blob)

When I'm saving with active record 4.0.2 the script that just worked suddenly crashes with "Error: invalid byte sequence in UTF-8" .. is there any gotcha in what format optimize_image_data() returns the optimized data?

from image_optim.

ippa avatar ippa commented on May 28, 2024

Hm, ok. The IO.popen-hack returned ASCII-8BIT and optimized_image_data returns UTF-8. I'll have to dig further on my side why it crashes my database save, not a image_optim problem. Thanks again!

from image_optim.

toy avatar toy commented on May 28, 2024

In reality optimize_image_data should return binary data. I'll put it into master after testing.

from image_optim.

toy avatar toy commented on May 28, 2024

v0.10.1 out

from image_optim.

ippa avatar ippa commented on May 28, 2024

Things are moving fast, I like it :). Just got bitten by another thing ...optimize_image_data seems to return nil if no optimization is done?

Maybe that's the desired behavior? I was just expecting it to return imagedata as optimized as possible (sometimes that means the original image).

from image_optim.

toy avatar toy commented on May 28, 2024

nil is returned to indicate failure. Otherwise you would have to compare result with original to determine success. optimize_image and optimize_image! also return nil on failure. If you don't care if optimization was successful or not just use image_optim.optimize_image_data(data) || data.

from image_optim.

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.