The code you currently have is making use of a temporary file that has just been sent to the server:
$filter = new ImageFilter;
$score = $filter->GetScore($_FILES['photoimg']['tmp_name']);
To use a file that already exists, just provide the path and its name:
$caminho = "/caminho/completo/para/a/minha/imagem/";
$imagem = "nomeDaImage.jpg";
$filter = new ImageFilter;
$score = $filter->GetScore($caminho.$imagem);
Elaboration
The code in the question comes from a class written in PHP that clears the score of a certain image for the purpose of preventing the upload of images "to adults" or containing "nudism".
To class comes from the site phpclasses.org, site courtesy of our esteemed @mlemos, having been developed and published by Bakr Alsharif:
We can observe in the method used GetScore
that it invokes the method _GetImageResource
passing the argument without amendment:
function GetScore($image)
{
$x = 0; $y = 0;
$img = $this->_GetImageResource($image, $x, $y);
// ...
}
Already in the method _GetImageResource
, It passes the argument, again without changes, to various PHP functions, all of them expecting to receive a path to an existing file:
function _GetImageResource($image, &$x, &$y)
{
$info = GetImageSize($image);
$x = $info[0];
$y = $info[1];
switch( $info[2] )
{
case IMAGETYPE_GIF:
return @ImageCreateFromGif($image);
case IMAGETYPE_JPEG:
return @ImageCreateFromJpeg($image);
case IMAGETYPE_PNG:
return @ImageCreateFromPng($image);
default:
return false;
}
}
See documentation for getimagesize()
, imagecreatefromgif()
, imagecreatefromjpeg()
and imagecreatefrompng()
.
Theoretically, the image exists on the server, but is temporary until PHP finishes running. You want to save it somewhere else?
– Lucas