Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Dan Tenenbaum
verbose inspect? [ reply ]  
2010-05-18 22:02
Hi,
How do I do the equivalent of this convert command in RMagick?

convert image.jpg -verbose -identify -colors

This gives me several screens worth of information about the image.

  • By: Omer Bar-or
    RE: verbose inspect? [ reply ]  
    2010-05-25 15:56
    Hi, Dan -

    Sorry to take so long to get back to you. I don't believe that we have such a feature exists in RMagick right now. The most verbose output we have is when you inspect an image.

    Please add this as a feature request.

    Thanks,
    - Omer.

By: Aryk Grosz
Crazy Memory Leak - magick_image.dup.destroy! [ reply ]  
2010-05-13 18:49
I was trying to figure out why my application was leaking memory like crazy. When I boiled it down, I found out that any operation which caused a Magick::Image to return a new instance of itself was causing memory to get used and then not released, even if "destroy!" afterwards.

I'm aware of the "destroy!" and the "GC.start" trick. That doesn't help. I tried just duping and then destroying the image and memory still climbs like crazy.

I have this line:

magick_image.dup.destroy!

When it is uncommented my memory usage for Ruby climbs past 1GB. When it is commented out, my memory usage stays under 100MB.

Any ideas? I'm using version 2.12.2



  • By: Aryk Grosz
    RE: Crazy Memory Leak - magick_image.dup.destroy! [ reply ]  
    2010-05-14 23:17
    Anybody have any ideas? I'm pretty stumped...

    • By: Omer Bar-or
      RE: Crazy Memory Leak - magick_image.dup.destroy! [ reply ]  
      2010-05-15 06:38
      Hey, Aryk -

      I'll look into this. Do you mind putting together a sample program that exhibits the behavior? That would make my life much easier.

      Also, which version of ImageMagick and which OS/version are you using?

      Thanks,
      - Omer.

      • By: Aryk Grosz
        RE: Crazy Memory Leak - magick_image.dup.destroy! [ reply ]  
        2010-05-17 20:25
        Omer,

        Here it is:

        ruby -e "require 'rubygems' ; require 'rmagick'; 1000.times {m = Magick::Image.new(3000, 3000) ; m.dup.destroy! ; m.destroy! ; sleep(2) } "

        Watch your memory slowly climb.

        Now, remove the "m.dup.destroy!" so it looks like this:

        ruby -e "require 'rubygems' ; require 'rmagick'; 1000.times {m = Magick::Image.new(3000, 3000) ; m.destroy! ; sleep(2) } "

        Your memory will be stable.

        My environment looks like this:
        - Mac OSX 10.5.8
        - ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin9.5.0]
        - ImageMagick 6.4.5 2010-02-01 Q8
        - rmagick (2.12.2)

        • By: Aryk Grosz
          RE: Crazy Memory Leak - magick_image.dup.destroy! [ reply ]  
          2010-05-18 23:46
          Hi Omer,

          Did you get a chance to look into this? Were you able to reproduce it?

          Thanks,
          Aryk

          • By: Omer Bar-or
            RE: Crazy Memory Leak - magick_image.dup.destroy! [ reply ]  
            2010-05-19 08:27
            Thanks for the sample code.

            I failed to reproduce the issue using the RMagick 2.13.1, ImageMagick 6.6.1, and Ubuntu 10.04. My memory usage stays approximately stable after running for several minutes.

            The oldest ImageMagick I have available is 6.4.9, and I'll try experimenting with that next.

            Is there anything keeping you from updating ImageMagick and RMagick to the latest versions to see if that works?

            Best,
            - Omer.

          By: Aryk Grosz
          RE: Crazy Memory Leak - magick_image.dup.destroy! [ reply ]  
          2010-05-19 18:36
          Omer,

          Thanks for your help. It's true, I tried this script on another box running actually the same versions of IM and Rmagick and memory was stable.

          The only thing different was that I was using OpenMP and Q16 instead of Q8. The environment was also different (linux).

          I will try upgrading, that would probably fix the issue!

          Thanks again,
          Aryk

By: Kenneth Ramey
Color Conversions [ reply ]  
2010-04-27 23:36
I have a PDF file that is a color-coded map. When I process it with RMagick and change to a JPG, the colors are changed. I have tried several ColorSpaces without success. The colors must be maintained because they are used to indicate special areas and conditions on the map.

Does anyone have any ideas how to maintain color integrity between the two files?

Thanks.

By: Jan-Yves Ruzicka
Changing architecture of RMagick2.bundle? [ reply ]  
2010-04-06 23:48
I've been trying to install rmagick (through rubygems) for a bit now, and I keep hitting problems. I'm pretty sure I've worked out the main problem now: lib/RMagick2.bundle is being installed as 64-bit on my 32-bit system. I'm not sure why this is happening, but OS X 10.6 Snow Leopard seems to love assuming it's on a 64-bit computer no matter what.

Is there any way to install rmagick through gems and specify the architecture? I'm looking specifically at the creation of RMagick, since the rest of it seems fine.

  • By: Jan-Yves Ruzicka
    RE: Changing architecture of RMagick2.bundle? [ reply ]  
    2010-04-07 02:53
    OK, I've mucked about with stuff and found that no, it doesn't seem to be a problem with the architecture.

    FWIW, I'm running ruby 1.9.1 (i386-darwin9.7.0) on OS X 10.6.2 on a 2.1GHz Intel Core 2 Duo MacBook. I have ImageMagick 6.6.0 installed via MacPorts, and I'm trying to install RMagick 2.13.1.

    My problem is that when I try to require rmagick, I get the following error:

    LoadError: dlopen(/usr/local/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/lib/RMagick2.bundle, 9): no suitable image found. Did find:
    /usr/local/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/lib/RMagick2.bundle: mach-o, but wrong architecture - /usr/local/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/lib/RMagick2.bundle
    from /usr/local/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/lib/rmagick.rb:11:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/rmagick-2.13.1/lib/rmagick.rb:11:in `<top (required)>'
    from (irb):2:in `require'
    from (irb):2
    from /usr/local/bin/irb:12:in `<main>'

    Running `file` on RMagick2.bundle gives:

    RMagick2.bundle: Mach-O 64-bit bundle x86_64

    However, if I make a simple hello world.c and compile it using cc I get the same info on file, and that will run fine.

    So, yeah. I'm a wee bit stumped. Any ideas?

By: Joe Harbinson
resize_to_fit question [ reply ]  
2010-03-26 14:19
I am using the resize_to_fit method to resize some logos that are uploaded by a user. I have a fixed container size (200px X 160px) in which I can display the logo. It has been working fine when .png files are uploaded at 800px wide. however, a user uploaded a .png that was 2157px X 1027px, and the thumbnail was created, however the aspect ratio wasn't maintained. I reduced the size of the original image to 800px wide, and re-uploaded and the thumbnail worked correctly maintaining the aspect ratio.

Is there some dimension limitation for using resize_to_fit? Here is my code:
img.resize_to_fit(width.round,height.round).write("public"+finalPath) if !File.exist?("public"+finalPath)

Where I am passing 200 as the width and 160 as the height.

Thanks.

  • By: Omer Bar-or
    RE: resize_to_fit question [ reply ]  
    2010-03-29 15:01
    Hi, Joe -

    Thanks for providing a code snippet. That really helps!

    When I use your code on a .png with size 2157px X 1027px, I get the expected result: a .png with size 200px X 95px. I ran this on Ubuntu 9.10 using RMagick 2.13.0 and ImageMagick 6.5.8-7.

    Do you mind giving me the following info:
    a) your OS
    b) which version of RMagick you are using
    c) which version of ImageMagick you are using

    My suspicion is that the issue is due to an old version of either RMagick or ImageMagick.

    Thanks.

By: a reith
Error on RMagick 2.12/2.13 under Windows [ reply ]  
2010-03-31 01:39
Hello the list !
I've got some bugs on the gem RMagick 2.12.0 win32 package (Ruby 1.8.7p249 mingw32). Had the same errors with different configuration (older RMagick package, older ImageMagick, Ruby 1.8.6 mswin32, and with the latest rmagick 2.13 take from github and compiled with the DevKit mingw from RubyInstaller).

1st error : don't pass all the tests. in example (take from RMagick/test/Image3.rb line 986 ) :

require 'rubygems'
gem 'rmagick', '=0.0.0' # lastest github gem doesn't fix gem version
require 'rmagick'
img = Magick::Image.new(20,20)
f = File.new("test.0", "w")
img.write(f) { self.format = "JPEG" } # --> ruby crash


2nd error : Where format list is also buggy :
on dos prompt :
identify -list format #--> list of format gived by ImageMagick

on irb :
Magick.formats
#-> Magick::ImageMagickError: image coder signature mismatch `XTRN': 3743c50 != 65608 @ module.c/OpenModule/1210
from C:/Ruby/lib/ruby/gems/1.8/gems/rmagick-0.0.0/lib/rmagick.rb:20:in `init_formats'
from C:/Ruby/lib/ruby/gems/1.8/gems/rmagick-0.0.0/lib/rmagick.rb:20:in `formats'
from (irb):6
from :0

if in the same irb session you call a second time the same :
Magick.formats
#=> {"PCDS"=>"*rw-", "MNG"=>"*rw+", "GRB"=>"*rw+", "YCbCr"=>"*rw+", .... work fine this time.


So did you have some ideas about thoses errors ??

Thanks,

Traz

By: Jesse Clark
Issue installing 2.13.0 from downloaded gem [ reply ]  
2010-02-19 01:26
On ruby 1.8.6 after installing Imagemagick 6.5.9 Q8 from MacPorts and rmagick 2.12.2 from rubygems I hit the

dyld: Symbol not found: _DestroyConstitute

issue.

2.13.0 isn't available through rubygems so I downloaded the gem file and tried to install from that but it fails with this error:

rmpixel.c: In function ‘Pixel_from_hsla’:
rmpixel.c:534: error: ‘MagickLibSubversion’ undeclared (first use in this function)
rmpixel.c:534: error: (Each undeclared identifier is reported only once
rmpixel.c:534: error: for each function it appears in.)
make: *** [rmpixel.o] Error 1

Is there any work around for this?

Also, I am not sure if this matters but I have ruby installed via RVM.

Thanks.

  • By: Omer Bar-or
    RE: Issue installing 2.13.0 from downloaded gem [ reply ]  
    2010-02-19 03:56
    Hi, Jesse -

    No released version of RMagick works with the latest version of ImageMagick. Our fix for the above issues is already in CVS and git and will likely get released soon.

    That said, I believe that you have three choices:
    a) Wait for the next release of RMagick. (If you choose this option, let me know so that we can try to release sooner.)
    b) Compile RMagick from source.
    c) Use an older version of ImageMagick. RMagick 2.13.0 should work with ImageMagick 6.4.9-6.5.8, and RMagick 2.12.2 should work with ImageMagick 6.4.9-6.5.6.

    Good luck!

    • By: Jean-Marc Pelletier
      RE: Issue installing 2.13.0 from downloaded g [ reply ]  
      2010-03-23 10:22
      If RMagick is not compatible with the latest ImageMagick, then this needs to be made explicitly clear in the installation FAQ. I am running Snow Leopard and Macports will only provide me with 6.6.0.

      I tried using sources from Github, but config.rb also fails.

      Here's a relevant excerpt from mkmf.log:


      have_library: checking for InitializeMagick() in -lMagick... -------------------- no

      "gcc -o conftest -I. -I/usr/local/lib/ruby/1.8/universal-darwin8.0 -I/Users/jmp/Downloads/rmagick-rmagick-d42ba04/ext/RMagick -I/opt/local/include/ImageMagick -I/opt/local/include/ImageMagick -fopenmp conftest.c -L"/usr/local/lib" -L/opt/local/lib -L/opt/local/lib -L/opt/local/lib -L/opt/local/lib -arch i386 -L/opt/local/lib -lMagickCore -llcms -ltiff -lfreetype -ljpeg -L/opt/local/lib -lfontconfig -lexpat -lfreetype -lz -liconv -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lgomp -lclparser -framework OpenCL -L/System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries -lm -lpthread -lruby-static -lMagick -lpthread -ldl -lobjc "
      conftest.c: In function 't':
      conftest.c:13: warning: 'InitializeMagick' is deprecated (declared at /opt/local/include/ImageMagick/magick/deprecate.h:304)
      ld: library not found for -lMagick
      collect2: ld returned 1 exit status
      checked program was:
      /* begin */
      1: #include <assert.h>
      2: #include <ctype.h>
      3: #include <stdio.h>
      4: #include <stdlib.h>
      5: #include <math.h>
      6: #include <time.h>
      7: #include <stdint.h>
      8: #include <sys/types.h>
      9: #include <wand/MagickWand.h>
      10:
      11: /*top*/
      12: int main() { return 0; }
      13: int t() { void ((*volatile p)()); p = (void ((*)()))InitializeMagick; return 0; }
      /* end */

      "gcc -o conftest -I. -I/usr/local/lib/ruby/1.8/universal-darwin8.0 -I/Users/jmp/Downloads/rmagick-rmagick-d42ba04/ext/RMagick -I/opt/local/include/ImageMagick -I/opt/local/include/ImageMagick -fopenmp conftest.c -L"/usr/local/lib" -L/opt/local/lib -L/opt/local/lib -L/opt/local/lib -L/opt/local/lib -arch i386 -L/opt/local/lib -lMagickCore -llcms -ltiff -lfreetype -ljpeg -L/opt/local/lib -lfontconfig -lexpat -lfreetype -lz -liconv -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lgomp -lclparser -framework OpenCL -L/System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries -lm -lpthread -lruby-static -lMagick -lpthread -ldl -lobjc "
      conftest.c: In function 't':
      conftest.c:13: warning: 'InitializeMagick' is deprecated (declared at /opt/local/include/ImageMagick/magick/deprecate.h:304)
      conftest.c:13: error: too few arguments to function 'InitializeMagick'
      checked program was:
      /* begin */
      1: #include <assert.h>
      2: #include <ctype.h>
      3: #include <stdio.h>
      4: #include <stdlib.h>
      5: #include <math.h>
      6: #include <time.h>
      7: #include <stdint.h>
      8: #include <sys/types.h>
      9: #include <wand/MagickWand.h>
      10:
      11: /*top*/
      12: int main() { return 0; }
      13: int t() { InitializeMagick(); return 0; }
      /* end */

      • By: Omer Bar-or
        RE: Issue installing 2.13.0 from downloaded g [ reply ]  
        2010-03-29 15:10
        You're right that we've been negligent about checking new versions of ImageMagick quickly and updating/releasing RMagick to deal with those versions. We'll also start listing the last tested version of ImageMagick when we release a new version of RMagick.

        A new version should be out shortly that works with the latest ImageMagick.

        Until then, Ruby 2.13.0 was released after testing with 6.4.9 <= ImageMagick version <= 6.5.7-9.

By: Ben Blakley
RVG text_anchor end with tspans [ reply ]  
2010-02-08 21:31
I'm trying to write multiple lines of wrapped text with a mix of formatting within the text (e.g. bolding one word, italicizing another, etc.). If I understand it correctly those two features aren't available in RMagick's Draw feature but are through RVG. So I tried using RVG but my other requirement is to have the text aligned to the right. I read that this is done through :text_anchor => "end" but when I do this the text generated by each tspan stacks up on top of each other. Here's some demo code:

http://pastie.org/814964

Is there a way to do this? I'm running RMagick 2.11.1 and ImageMagick 6.4.8-7 on Mac OS 10.6.2. Thanks!

Ben

By: Gilbert Serex
Output file attributes [ reply ]  
2010-03-15 16:21
Hello everyone,

I apologise if that has already been covered.

I am using Imagemagick to convert image files sent to a (Linux) server to a set size (say 500px wide and proportionally re-sizes the vertical part etc...)

This is called via a Perl script's "system" command.

Up to now, this script was hosted on a server that had no issues in resizing the pics, however I since moved the script onto a new server and the images being converted are created with different access rights, sometimes it's rwxr--r-- and sometimes it's rwxr-xr-x, the work around so far is to have a system chmod call after the system convert call.

I would like to know if there is a configuration setting to enable etc. in order to have the same permissions set at each conversion.

The worst part is that a user will upload a pic and it will be fine and someone else might do the same and the image is broken, (it's there but it not permitted to be shown in the browser, you get a permission denied), and it's AFAIK totally random as well.

Thank you for any help and sorry if it is covered somewhere I haven't yet found.

Cordially

Gilbert

By: Rodney Woodruff
Maintain Transparency in Resized Tiff [ reply ]  
2010-02-25 23:56
Hello,

I am trying to resize and crop a tiff file and convert it to a png while maintaining the original file's transparency. Below is the code that I used. Can someone tell me how to accomplish this?

===== BEGIN SAMPLE =========
imgs = []
imgs = Image.read("./images/232973_FWCFN_9791_001_reflection.tif") {self.background_color = 'none'}

img = imgs[0] if imgs.size > 0
puts imgs.size.to_s

if img
img.background_color = 'none'
final_img = img.crop(56, 0, 1032, 2000).resize(260, 504, LagrangeFilter).unsharp_mask(1, 1.0, 0.5, 0)
final_img.write("png24_revised_reflection_mini_thumb_100.png") {self.background_color = 'none'}
end
========== END SAMPLE =========

Thank you in advance for your help.

By: Rodney Woodruff
Capturing Commands RMagick is sending [ reply ]  
2010-03-01 20:26
Hello,

Is there a flag I can turn on that will allow me to see what the command line options to ImageMagick are when I am using RMagick? I am trying to troubleshoot an issue that I am having and want to make sure that RMagick is doing what I think or if I am just stupid.

Thanks.

-- Rodney

  • By: Omer Bar-or
    RE: Capturing Commands RMagick is sending [ reply ]  
    2010-03-02 05:36
    Hi, Rodney -

    RMagick does not call the ImageMagick command line. It interacts with the ImageMagick libraries directly. So, there is often no equivalent ImageMagick command line call to an RMagick expression. That said, if you're familiar with C, it is decently straight-forward to go from an RMagick expression to a function in the RMagick C library, and many RMagick functions are just wrappers around ImageMagick functions.

By: Rodney Woodruff
Reproduce Photoshop Image size [ reply ]  
2010-03-01 23:08
Hello,

I am using RMagick to generate thumbnails that used to be done in photoshop because the volume has become way too large.

However, the thumbnails generated by RMagick are 32K and the thumbnails generated by Photoshop is 8K. Can some tell me how to get close to the photoshop size. Below is the sample code and the my environment details.

The only thing that I can think of as affecting the size is that Photoshop uses bicubic interpolation on the resize but ImageMagick doesn't appear to be able to do that.

Any and all help is appreciated.

Environment:
Ruby 1.8.7,
Leopard 10.5.8,
rmagick 2.12.2,
ImageMagick: 6.5.8-0 2010-02-25 Q16

Sample Code (testing filters with process from photoshop):

img = Image.read("./images/232973_FWCFN_9791_001.tif").first

filters = [
Magick::UndefinedFilter,
Magick::BesselFilter,
Magick::BlackmanFilter,
Magick::BoxFilter,
Magick::CatromFilter,
Magick::CubicFilter,
Magick::GaussianFilter,
Magick::HammingFilter,
Magick::HanningFilter,
Magick::HermiteFilter,
Magick::KaiserFilter,
Magick::LagrangeFilter,
Magick::LanczosFilter,
MitchellFilter,
Magick::ParzenFilter,
Magick::PointFilter,
Magick::QuadraticFilter,
Magick::SincFilter,
Magick::TriangleFilter,
Magick::WelshFilter
]

if img
filters.each do |filter|
final_img = img.crop(56, 300, 1088, 1334).resize(130, 168, filter, 0.8).unsharp_mask(1, 1.0, 0.5, 0)
final_img.write("./newimages/revised_mini_thumb_#{filter.to_s}.jpg") {self.quality = 50}
end
end


By: Marc Rohloff
Problem with Draw.draw and forked processes [ reply ]  
2008-10-23 21:07
I have an image generation routine which initially generates images in the main thread but then switches over to forked processes to take advantage of a multi-CPU machine. I can approcimate this with the following code:

----------------
require "rubygems"
require "RMagick"

def foo(p)
puts " > foo(#{p})"
image = Magick::Image.new(100,100)
puts " 1 foo(#{p})"
draw = Magick::Draw.new
puts " 2 foo(#{p})"
draw.line(0,0,100,100)
puts " 3 foo(#{p})"
draw.draw(image)
puts " < foo(#{p})"
end

def test1
puts ">test1"
foo('s')
puts "<test1"
end

def test2
puts ">test2"
p1 = fork {foo('f1')}
p2 = fork {foo('f2')}
puts " waiting"
Process.waitall
puts "<test2"
end

puts RUBY_VERSION
puts Magick::Version
puts Magick::Magick_version
test1
test2
-----------------
If I run just single threaded (just test1) or frked (just test2) then everything works as expected hwever if I run test1 followed by test2 then the two forked processes hang at the Draw.draw call.

Is there a way to work around this?

--
Marc

By: Ben Blakley
RVG shadow/blur [ reply ]  
2010-02-23 17:20
I have another question on using RVG. This time I'm trying to create a drop shadow. I saw the example in the RMagick docs that use Draw's annotate method and then Image's blur method. I tried using blur on an RVG rendered image but the edges of the text don't blur, only the inside of the letters are affected. Here's a sample of what I'm trying to do:

http://pastie.org/838897

I thought setting the image's virtual_pixel_method to TransparentVirtualPixelMethod might help but it didn't. What am I doing wrong? Thanks for the help.

Ben

By: Matthew Linnell
Fails check on ImageMagick 6.4.9+, have 6.5.8 [ reply ]  
2010-02-19 16:17
Just tried installing rmagick on an openSuse (11.1) box. I compiled/installed Ruby (1.8.7p174) manually.

However, when I try to install rmagick (locally, from the 2.13 gem) I get the following output:

> sudo gem install rmagick-2.13.0.gem
Building native extensions. This could take a while...
ERROR: Error installing rmagick-2.13.0.gem:
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... yes
checking for ImageMagick version >= 6.4.9... no
Can't install RMagick 2.13.0. You must have ImageMagick 6.4.9 or later.

*** 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=/usr/local/bin/ruby



I know the image magick binaries are in my path, because it shows up from a 'which convert' (result: /usr/local/bin/convert), and I also know that it is the correct version of ImageMagick, convert --version gives me 6.5.8-10.


I did have older versions of ImageMagick and libraries installed via yast, but I went ahead and removed them, and did another configure/make/make install of ImageMagick from source. Still, the problem persists. I'm sure I need to do a configuration option with a path, I'm just not sure which option or which path.

regards,
Matt

Previous Messages  Next Messages