GithubHelp home page GithubHelp logo

sdsykes / fastimage_resize Goto Github PK

View Code? Open in Web Editor NEW
79.0 79.0 19.0 277 KB

FastImage Resize is an extremely light solution for resizing images in ruby by using libgd

License: MIT License

Ruby 100.00%

fastimage_resize's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fastimage_resize's Issues

Reading streams and returning File (or other object responding to #read)

Excellent gem! MiniMagick was too slow for on-the-fly resizes and this really speeded things up!

One thing that'd be useful is the ability to read from streams (an object responding to #read). Currently I need to save database files to disk, resize them to a new path on disk and lastly open the resized_path and return it (File.open(path_written_by_fastimage_resize)).

Missing libgd when building gem native extension

In our Rails project we want to use the gem local-fastimage_resize which requires libgd. According to the doc (and the Internet) it should be possible to install it by means of homebrew but when we try to install the gem it can't find the library.

Here are some logs from my M1 mac:

$ brew info libgd
==> gd: stable 2.3.3 (bottled), HEAD
Graphics library to dynamically manipulate images
https://libgd.github.io/
/opt/homebrew/Cellar/gd/2.3.3_3 (33 files, 1.5MB) *
  Poured from bottle on 2022-10-10 at 12:18:49
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/gd.rb
License: Cannot Represent
==> Dependencies
Required: fontconfig ✔, freetype ✔, jpeg-turbo ✔, libavif ✔, libpng ✔, libtiff ✔, webp ✔
==> Options
--HEAD
	Install HEAD version
==> Analytics
install: 147,026 (30 days), 503,823 (90 days), 1,624,252 (365 days)
install-on-request: 17,867 (30 days), 55,417 (90 days), 144,616 (365 days)
build-error: 0 (30 days)
$ gem install local-fastimage_resize -- --with-gdlib=/opt/homebrew/Cellar/gd/2.3.3_3
Building native extensions with: '--with-gdlib=/opt/homebrew/Cellar/gd/2.3.3_3'
This could take a while...
ERROR:  Error installing local-fastimage_resize:
	ERROR: Failed to build gem native extension.

    current directory: /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/local-fastimage_resize-3.4.0/ext/fastimage_native_resize
/Users/jgallaso/.asdf/installs/ruby/2.6.8/bin/ruby -I /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/2.6.0 -r ./siteconf20221010-18826-otaeca.rb extconf.rb --with-gdlib\=/opt/homebrew/Cellar/gd/2.3.3_3
checking for -l/opt/homebrew/Cellar/gd/2.3.3_3... no
missing libgd
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/jgallaso/.asdf/installs/ruby/2.6.8/bin/$(RUBY_BASE_NAME)
	--with-gdlib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/extensions/arm64-darwin-21/2.6.0/local-fastimage_resize-3.4.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/local-fastimage_resize-3.4.0 for inspection.
Results logged to /Users/jgallaso/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/extensions/arm64-darwin-21/2.6.0/local-fastimage_resize-3.4.0/gem_make.out

I've also tried installing libgd manually following instructions in INSTALL but no matter the path --with-gdlib it will return the same error.

Any ideas? 😖

Output image is always 96dpi

I have tried many different images (png and jpg) and the output image after resize is always 96dpi when the original images were al 72dpi. Any thoughts on why this could be?

Doc outdated?

Get a: uninitialized constant RAILS_ROOT

what worked for me:

ENV['INLINEDIR'] = Rails.root.join("tmp").to_s # for RubyInline

Temp file should be open in binary mode...?

Hello

Running on ruby 1.9.2 + rails 3.1.2, i got Encoding::UndefinedConversionError exception when calling FastImage.resize.

Dug in, and found that filemode is not binary.

workaround - added
temp.binmode
to fastimage_resize.rb :: read_to_local

New method code:

def self.read_to_local(readable)
    temp = Tempfile.new(name)
    temp.binmode # <--
    temp.write(readable.read)
    temp.close
    temp.open
    temp
end

Terminate process when resize image

Example image: https://www.magazin-hp.ru/image/cache/catalog/06_server/hp-server-power/hp_power_460W_001-600x600.png

GD Error: gd-png: fatal libpng error: Read Error: truncated data
GD Warning: gd-png error: setjmp returns error condition 2
/home/maroki/.rvm/gems/ruby-2.3.4/gems/fastimage_resize-2.0.3/lib/fastimage_resize.rb:90: [BUG] Segmentation fault at 0x0000000000000c
ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0048 p:---- s:0215 e:000214 CFUNC :resize_image
c:0047 p:0308 s:0206 e:000205 METHOD /home/maroki/.rvm/gems/ruby-2.3.4/gems/fastimage_resize-2.0.3/lib/fastimage_resize.rb:90
c:0046 p:0020 s:0190 e:000189 EVAL (pry):1 [FINISH]
c:0045 p:---- s:0188 e:000187 CFUNC :eval

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.