Well, that finally worked.
I have another question regarding this.
I changed the function for use with the photos that are added with stories. I do not knw how to add this function into my code, for use in naming conventions. Here is what I have, how would I change this to work?
exec("cp $custom3 /tmp/$custom3_name");
$tmpimg = "/tmp/$custom3_name";
$newfile = "/projects/sunarchive/htdocs/image/";
$newphoto = "$newfile . photoid() . '.jpg'";
$new_w=140;
$new_h=191;
system("convert -quality 80 -antialias -sample '$new_wx$new_h' '$tmpimg' '$newphoto'");