I want to check the size of an image file before I write it.
If it is a certain size, then I won't write it.
Can I check the future size of the file by
using strlen() on the file_get_conten ts($url);?
Here is my script:
First I get the image from an image website,
but if the image is the standard error image ( "Can't find image" ),
then I don't want to save it:
( The size of this standard error image is always 4.49Kb )
Or is there a better way to do this ?
The other thing I could do is write the file with the
file_put_conten ts() then check the file size, then delete if
it is the "standard" size. But that seems a waste of resources.
Any ideas ?
If it is a certain size, then I won't write it.
Can I check the future size of the file by
using strlen() on the file_get_conten ts($url);?
Here is my script:
First I get the image from an image website,
but if the image is the standard error image ( "Can't find image" ),
then I don't want to save it:
( The size of this standard error image is always 4.49Kb )
Code:
$image_data = file_get_contents($url);
IF( strlen($image_data) != ?? ) { // don't know what this should be
if($image_data === FALSE) {
write_log("$ctr )$id PROBLEM with READ \r\n");
}
else {
write_log("$ctr )Processing $image_loc \r\n");
$file_size = file_put_contents($image_loc, $image_data);
if($file_size === FALSE) {
write_log("$ctr )$id PROBLEM with WRITE \r\n");
}
else {
write_log("$ctr )$id Image created size : $file_size\r\n");
}
}
} // END IF
The other thing I could do is write the file with the
file_put_conten ts() then check the file size, then delete if
it is the "standard" size. But that seems a waste of resources.
Any ideas ?
Comment