• 24-07-2022, 21:23:42
    #1
    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', 'On');
    /* The object used as a canvas */
    $canvas = new imagick( "fake_wood_plastic_formica_4131428.jpg" );
    $canvas->adaptiveResizeImage( 300, 300 );
    $canvas->setImageFormat( "png" ); /* paths to the images */
    $paths = array( "chev7.jpg", "myfrog.jpg", "strawberry.jpg", "Image32.jpg" ); /* Create an empty ImagickDraw object (Use the defaults for the polaroid) */
    $bg = new ImagickDraw(); /* Create a few random images */
    $images = new Imagick( $paths ); /* Loop trough images, overlay on canvas and remove the image */
    foreach ( $images as $key => $image )
     { /* Thumbnail to 100x width and set background to black. It looks like an drop-in shadow :) */ $image->thumbnailImage( 100, null );
     $image->setImageBackgroundColor( new ImagickPixel( "black" ) );
     /* Use a random angle */ $angle = mt_rand( 1, 45 ); 
    if ( mt_rand( 1, 2 ) % 2 === 0 ) { $angle = $angle * -1; } /* Create the polaroid */ $image->polaroidImage( $bg, $angle );
     /* Composite the polaroid over the canvas */ /* Composite to a random location */ $canvas->compositeImage( $image, Imagick::COMPOSITE_OVER, mt_rand( 10, 150 ), mt_rand( 10, 150 ) );
     /* Free some resources */ $image->removeImage(); } /* Display the image */
    header( "Content-Type: image/png" );
    echo $canvas;  ?>
    hata: error: Fatal error: Uncaught ImagickException: Can not process empty Imagick object in /home/kpsspuan/public_html/twitter/save.php:22 Stack trace: #0 /home/kpsspuan/public_html/twitter/save.php(22): Imagick->valid() #1 {main} thrown in /home/kpsspuan/public_html/twitter/save.php on line 22


    Arkadaşlar sizce bu hatayı nasıl aşarım eskiden bu kod çalışıyormuş sanırım çözemedim.

    daha düzenli hali: https://paste.ofcode.org/xPtNtBqHB9MserTyvXcHUN
  • 25-07-2022, 03:06:20
    #2
    Bu şekilde dener misin ?
    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', 'On');
    /* The object used as a canvas */
    $canvas = new imagick( "fake_wood_plastic_formica_4131428.jpg" );
    $canvas->adaptiveResizeImage( 300, 300 );
    $canvas->setImageFormat( "png" ); /* paths to the images */
    $paths = array( "chev7.jpg", "myfrog.jpg", "strawberry.jpg", "Image32.jpg" ); /* Create an empty ImagickDraw object (Use the defaults for the polaroid) */
    $bg = new ImagickDraw(); /* Create a few random images */
    
    foreach ( $paths as $key => $image )
    $images = new Imagick( $image ); /* Loop trough images, overlay on canvas and remove the image */
     { /* Thumbnail to 100x width and set background to black. It looks like an drop-in shadow :) */ $image->thumbnailImage( 100, null );
     $image->setImageBackgroundColor( new ImagickPixel( "black" ) );
     /* Use a random angle */ $angle = mt_rand( 1, 45 );
    if ( mt_rand( 1, 2 ) % 2 === 0 ) { $angle = $angle * -1; } /* Create the polaroid */ $image->polaroidImage( $bg, $angle );
     /* Composite the polaroid over the canvas */ /* Composite to a random location */ $canvas->compositeImage( $image, Imagick::COMPOSITE_OVER, mt_rand( 10, 150 ), mt_rand( 10, 150 ) );
     /* Free some resources */ $image->removeImage(); } /* Display the image */
    header( "Content-Type: image/png" );
    echo $canvas;  ?>
  • 25-07-2022, 09:10:47
    #3
    https://stackoverflow.com/questions/...ing-this-error bir göz at istersen yardımcı olabilir.
  • 25-07-2022, 14:33:36
    #4
    Heaven_Tr adlı üyeden alıntı: mesajı görüntüle
    Bu şekilde dener misin ?
    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', 'On');
    /* The object used as a canvas */
    $canvas = new imagick( "fake_wood_plastic_formica_4131428.jpg" );
    $canvas->adaptiveResizeImage( 300, 300 );
    $canvas->setImageFormat( "png" ); /* paths to the images */
    $paths = array( "chev7.jpg", "myfrog.jpg", "strawberry.jpg", "Image32.jpg" ); /* Create an empty ImagickDraw object (Use the defaults for the polaroid) */
    $bg = new ImagickDraw(); /* Create a few random images */
    
    foreach ( $paths as $key => $image )
    $images = new Imagick( $image ); /* Loop trough images, overlay on canvas and remove the image */
     { /* Thumbnail to 100x width and set background to black. It looks like an drop-in shadow :) */ $image->thumbnailImage( 100, null );
     $image->setImageBackgroundColor( new ImagickPixel( "black" ) );
     /* Use a random angle */ $angle = mt_rand( 1, 45 );
    if ( mt_rand( 1, 2 ) % 2 === 0 ) { $angle = $angle * -1; } /* Create the polaroid */ $image->polaroidImage( $bg, $angle );
     /* Composite the polaroid over the canvas */ /* Composite to a random location */ $canvas->compositeImage( $image, Imagick::COMPOSITE_OVER, mt_rand( 10, 150 ), mt_rand( 10, 150 ) );
     /* Free some resources */ $image->removeImage(); } /* Display the image */
    header( "Content-Type: image/png" );
    echo $canvas;  ?>
    şu hatayı veriyor hocam Fatal error: Uncaught Error: Call to a member function thumbnailImage() on string in /home/kpsspuan/public_html/twitter/save.php:13 Stack trace: #0 {main} thrown in /
  • 25-07-2022, 14:35:33
    #5
    salihbey24 adlı üyeden alıntı: mesajı görüntüle
    https://stackoverflow.com/questions/...ing-this-error bir göz at istersen yardımcı olabilir.
    imagick etekdeğer veriyoruz buradaki kodda doğru.
  • 26-07-2022, 00:48:23
    #6
    Misafir adlı üyeden alıntı: mesajı görüntüle
    şu hatayı veriyor hocam Fatal error: Uncaught Error: Call to a member function thumbnailImage() on string in /home/kpsspuan/public_html/twitter/save.php:13 Stack trace: #0 {main} thrown in /
    düzelttiğim kod çalışmış. thumbnailImage() diye bir fonksiyon çağırıyorsun kodunda bu kod buraya paylaştığın kod içerisinde yer almıyor. resimlerinin thumb larını oluşturacak fonksiyonun eksik.
  • 26-07-2022, 14:58:27
    #7
    Heaven_Tr adlı üyeden alıntı: mesajı görüntüle
    düzelttiğim kod çalışmış. thumbnailImage() diye bir fonksiyon çağırıyorsun kodunda bu kod buraya paylaştığın kod içerisinde yer almıyor. resimlerinin thumb larını oluşturacak fonksiyonun eksik.
    aslında içinde olması gerekiyor onun default imagick in içinde böyle olması gerekmiyor mu baktım hala var sanırım kaldırmamışlar