...

View Full Version : images cut problem



russia5
06-07-2007, 07:17 PM
I am trying to append one table with another table (MySQL): That is Profile_approval with Profile_delivery The there is data and images. The data appends find. The image paths are transferred, but the images themselves are not. I get the famous "x's" but the paths are correct. Below, is my code:





case 'deliver':

$query = 'SELECT * FROM Profile_approval';

$recordsToMove = mysql_query($query);

while ($recordToMove = mysql_fetch_assoc($recordsToMove))

{

$fields = $values = $images = array();

if ($recordToMove)

foreach ($recordToMove as $field=>$value)

{

if ($field != 'sid' and $field != 'free')

{

// remove uploads/

if (strpos($field, 'picture') !== false and $field != 'picture_default' and !empty($value))

{

$value = str_replace('uploads/', '', trim($value, '/'));

$oldImages[] = $value;

$value = 'Girl-'.preg_replace('/[^\w]/', '', $recordToMove['full_name']).'-'.sizeof($oldImages).'-'.date('Ymd').'.jpg';

$images[] = $value;

}



$fields[] = $field;

$values[] = '"'.$value.'"';

}

}



$query = 'INSERT INTO Profile_delivery ('.implode(',', $fields).') VALUES ('.implode(',',$values).')';

$res = @mysql_query($query);



if ($res)

{

# resize and copy images

if (!empty($images))

for ($i = 0; $i < sizeof($images); $i++)

{

$old = 'home/russia5/public_html/uploads/'.$oldImages[$i];

$new = 'home/russia5/public_html/images_original/'.$images[$i];

@copy($old, $new);

$thumb1 = 'home/russia5/public_html/images_thumb1/'.$images[$i];

$thumb2 = 'home/russia5/public_html/images_thumb2/'.$images[$i];

include('make_thumbs.php');



@chmod($new, 0777);

@chmod($thumb1, 0777);

@chmod($thumb2, 0777);



@unlink($old);

}



# delete record from approval table

$query = 'DELETE FROM Profile_approval';

@mysql_query($query);

}

}




The included make_thumbs.php script is:



<?php

$imgSize = 100;

$original_max_size = '600x600';
$thumb_size1 = '100x100';
$thumb_size2 = '300x300';

$command = '/usr/bin/convert';

//echo ($command);

// resize for thumbnail 1 size
$current_command = $command.$thumb_size1.' "'.$old.'" '.$thumb1;

//echo ($current_command);

exec($current_command, $retarray, $retval);
// echo $current_command;
if ($retval != 0) // error
{
echo 'error upon resizing for thumbnail 1 : '.$old.' to '.$thumb1;
}

// resize for thumbnail 2 size
$current_command = $command.$thumb_size2.' "'.$old.'" '.$thumb2;
exec($current_command, $retarray, $retval);
// echo $current_command;
if ($retval != 0) // error
{
// echo 'error upon resizing for thumbnail 2';
}
?>





Upon Appending the Profile_Delivery table with the Profile_Approval table, the data fields are appended, however the images are coming out with x's. The path to the images is correct implying the paths are appended correctly within the database. Below is the error that I am getting.



error upon resizing for thumbnail 1 : home/russia5/public_html/uploads/1181232172.jpg to home/russia5/public_html/images_thumb1/Girl-ddee-1-20070607.jpg



When the echo($current_command); is uncommented, we get:



/usr/bin/convert100x100


Can someone see what is wrong. I am thinking the problem might be in make_thumbs.php with the variables $retarray and $retval

Thanks for time spend from anyone.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum