mardi 12 février 2019

Extract inside photos from an Image with php

I have an image, it has combined with multiple images, how can i extract those inside photos?

Below is my sample photo

enter image description here

I have tried splitting a single image into multiple images. But this is not a correct way

<?php
$width = 100;
$height = 100;

$source = @imagecreatefromjpeg( "S29A57P1-3.jpg" );
$source_width = imagesx( $source );
$source_height = imagesy( $source );

for( $col = 0; $col < $source_width / $width; $col++)
{
  for( $row = 0; $row < $source_height / $height; $row++)
  {
    $fn = sprintf( "img%02d_%02d.jpg", $col, $row );

    echo( "$fn\n" );

    $im = @imagecreatetruecolor( $width, $height );
    imagecopyresized( $im, $source, 0, 0,
        $col * $width, $row * $height, $width, $height,
        $width, $height );
    imagejpeg( $im, $fn );
    imagedestroy( $im );
   }
}

Please suggest me the idea to extract inside photos from a photo using php.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire