I'm making a script that reads an xml and then trims the coordinates of it in the image and then saves it, but the "imagecrop" function always adds a black line at the end of the images and I just can not change the size and delete the black line since almost all arrive to the edge. I am using 2 codes, one generates the image and another low.
crop2.php
$ini_filename = 'assets/sprites/achievements.png';
$im = imagecreatefrompng($ini_filename);
$xml = simplexml_load_file('assets/sprites/achievements.xml');
foreach ($xml->SubTexture as $sub) {
$to_crop_array = array('x' => $sub['x'] , 'y' => $sub['y'], 'width' => $sub['width'], 'height' => $sub['height']);
$thumb_im = imagecrop($im, $to_crop_array);
if ($_GET['name'] == $sub['name']) {
imagepng($thumb_im);
}
}
and crop.php
<?php
ini_set('allow_url_fopen', TRUE);
$xml = simplexml_load_file('assets/sprites/achievements.xml');
foreach ($xml->SubTexture as $sub) {
file_put_contents('images/' . $sub['name'] . '.png', file_get_contents('http://localhost/apk/crop2?name=' . $sub['name']));
}
And I wanted to know how to remove this line without damaging anything.