The code you are currently using is 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, simply provide the path and name of it:
$caminho = "/caminho/completo/para/a/minha/imagem/";
$imagem = "nomeDaImage.jpg";
$filter = new ImageFilter;
$score = $filter->GetScore($caminho.$imagem);
Elaboration
The code in question comes from a class written in PHP that clears the score of a particular image for purposes of preventing uploading of images "for adults" or containing "nudism".
The class comes from site phpclasses.org , site courtesy of our estimated
Image Nudity Filter : Determining if an image can contain nudity
We can see in the method used GetScore
that it invokes the method _GetImageResource
passing the argument without changes:
function GetScore($image)
{
$x = 0; $y = 0;
$img = $this->_GetImageResource($image, $x, $y);
// ...
}
In the _GetImageResource
method, it passes the argument, again unchanged, to various PHP functions, all of which are waiting 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()
.