in reply to Re: Howto convert Image::Grab jpg object to Image::Magick object???
in thread Howto convert Image::Grab jpg object to Image::Magick object???

Do I need to use Blobs??

Did you try the code I posted? As far as I can tell from the docs, this should be all you need to get the $imgdata I showed in my other post:

use Image::Grab qw/grab/; my $imgdata = grab('http://upload.wikimedia.org/wikipedia/commons/1/1a +/Image_upload_test.jpg'); # - or - my $pic = Image::Grab->new; $pic->url('http://upload.wikimedia.org/wikipedia/commons/1/1a/Image_up +load_test.jpg') $pic->grab; my $imgdata = $pic->image;

(untested)

Replies are listed 'Best First'.
Re^3: Howto convert Image::Grab jpg object to Image::Magick object???
by dazz (Beadle) on Mar 27, 2017 at 09:45 UTC

    Hi

    I found this code sample that converts from GD to Image::Magick objects. It is like I want to do and it should work between any objects.

    Haukex, I will give your code a go.

    #!/user/bin/perl use strict; use Image::Magick; use GD; # First read an image with Image::Magick my $im = new Image::Magick; my $status = $im->Read('monkey.png'); if ($status) { die "$Status!"; } # Convert to a blob and hand off to GD my @blobs = $im->ImageToBlob(); my $gd = GD::Image->newFromPngData($blobs[0]); my $red = $gd->colorAllocate(255,0,0); # Outline in Red $dg->rectangle(0,0, (map {$_-1} $gd-?getBounds), $red); # There and back again my $im2 = new Image::Magick; $im2->BlobToImage($gd->png()); $im2->Write('png:monkeyout.png');

      For this example code, I'm not sure if you need the conversion to GD, since Image::Magick supports a ->Draw command. Here's another untested copy-n-paste from the docs you could try:

      $image->Draw(stroke=>'red', primitive=>'rectangle', points=>20,20 100, +100');

      Where $image is an Image::Magick object.

        Hi

        The GD is irrelevant in this case but it gives me a template to follow when applied to Image::Get and Image::Magick. I had found your docs reference but it doesn't show me how to pass an image from one object to a different type of object.

        Thanks for your time looking at this