SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict scoobasteve1982's Avatar
    Join Date
    Apr 2007
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using Imagick to output blog as image

    Hi there,

    I'm returning a BLOB (which is an image) and want to output raw blob data using Imagick as a thumbnail. Here's the code I have, however it doesn't seem to be working (cause I'm doing something wrong obviously). I have VERY little understanding of Imagick.

    PHP Code:
    require("IDXDbHandler.php");

    $mlsID $_GET['pid'];

    $res mssql_query("SELECT * FROM dbo.IDX_IMAGES WHERE mls_no = '$mlsID';");
    $data mssql_fetch_array($res);

    header ("Content-type: image/jpeg");

    //echo $data['image1'];

    $image = new Imagick($data['image1']);

    // If 0 is provided as a width or height parameter,
    // aspect ratio is maintained
    $image->thumbnailImage(1000); 
    I can output the image directly, but I was hoping to use Imagick to resize the image to a smaller size. If I provide a direct filename to the constructor it works well, but not with raw blob data. Any help would be greatly appreciated.

  2. #2
    SitePoint Addict scoobasteve1982's Avatar
    Join Date
    Apr 2007
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's some other code that I tried:

    PHP Code:
    try
    {
        
    $im = new Imagick();

        
    $im->readImageBlob$data['image1'] );

        
    $im->thumbnailImage100);

       
    $im->destroy();
    }
    catch(
    Exception $e)
    {
        echo 
    $e->getMessage();

    Where $data['image1'] is raw blob data pulled from a mySQL database. This however, is not working either. The image shows up as broken...

  3. #3
    SitePoint Addict scoobasteve1982's Avatar
    Join Date
    Apr 2007
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone? I really need to get this resolved as quick as possible and any help would be greatly appreciated. Thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •