Comments (7)
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.
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.
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.
In reality optimize_image_data
should return binary data. I'll put it into master after testing.
from image_optim.
v0.10.1 out
from image_optim.
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.
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)
- incompatible character encodings: UTF-8 and ASCII-8BIT HOT 9
- GPU vs CPU HOT 3
- Extended attribute status already compressed files HOT 4
- [Feature Request] an option to keep tags and comments when optimizing
- `advpng` installed on ubuntu, or OS X via homebrew, _does not_ have a proper version number HOT 14
- Consider OxiPng instead of OptiPNG HOT 2
- Support guetzli
- Specify a temp directory for the temporary files HOT 9
- Invalid cross-device link HOT 10
- After #optimize_image! the image is rotated HOT 1
- Req: Print only the list of optimized images HOT 2
- what are the permissions for here? HOT 3
- jpegoptim worker didn't strip comment HOT 2
- Add support for SVGo 2.x HOT 7
- Work as a pipe
- Don't overwrite by default
- Support webp
- Cannot load YAML config file that uses Range class in Ruby 3.1.x / Psych4.x HOT 2
- Ruby 3.2.0 / Rails 7.0.4 invalid byte sequence in UTF-8 (ArgumentError) HOT 4
- Cannot allocate memory - grep HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from image_optim.