$dest = imagecreatetruecolor( $dest_width, $dest_height );
- imagealphablending($dest->image, false);
+ imagealphablending($dest, false);
imagesavealpha($dest, true);
- if ($this->type=='image/png') imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127));; // fill with alpha
+ if ($this->type=='image/png') imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
if($this->image)
imagedestroy($this->image);
$dest = imagecreatetruecolor( $dest_width, $dest_height );
- imagealphablending($dest->image, false);
+ imagealphablending($dest, false);
imagesavealpha($dest, true);
- if ($this->type=='image/png') imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127));; // fill with alpha
+ if ($this->type=='image/png') imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dest_width, $dest_height, $width, $height);
if($this->image)
imagedestroy($this->image);
public function scaleImageSquare($dim) {
$dest = imagecreatetruecolor( $dim, $dim );
- imagealphablending($dest->image, false);
+ imagealphablending($dest, false);
imagesavealpha($dest, true);
- if ($this->type=='image/png') imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127));; // fill with alpha
+ if ($this->type=='image/png') imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
imagecopyresampled($dest, $this->image, 0, 0, 0, 0, $dim, $dim, $this->width, $this->height);
if($this->image)
imagedestroy($this->image);
public function cropImage($max,$x,$y,$w,$h) {
$dest = imagecreatetruecolor( $max, $max );
- imagealphablending($dest->image, false);
+ imagealphablending($dest, false);
imagesavealpha($dest, true);
- if ($this->type=='image/png') imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127));; // fill with alpha
+ if ($this->type=='image/png') imagefill($dest, 0, 0, imagecolorallocatealpha($dest, 0, 0, 0, 127)); // fill with alpha
imagecopyresampled($dest, $this->image, 0, 0, $x, $y, $max, $max, $w, $h);
if($this->image)
imagedestroy($this->image);
* @arg $fromcurl boolean Check Content-Type header from curl request
*/
function guess_image_type($filename, $fromcurl=false) {
+ logger('Photo: guess_image_type: '.$filename . ($fromcurl?' from curl headers':''), LOGGER_DEBUG);
$type = null;
if ($fromcurl) {
$a = get_app();
if (is_null($type)){
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$types = Photo::supportedTypes();
+ $type = "image/jpeg";
foreach ($types as $m=>$e){
- if ($ext==$e) return $m;
+ if ($ext==$e) $type = $m;
}
- $type = "image/jpeg";
- }
+ }
+ logger('Photo: guess_image_type: type='.$type, LOGGER_DEBUG);
return $type;
}
* @subpackage FileBrowser
* @author Fabio Comuni <fabrixxm@kirgroup.com>
*/
-
+
+require_once('include/Photo.php');
+
/**
* @param App $a
*/
$path[]=array($a->get_baseurl()."/fbrowser/image/".$a->argv[2]."/", $album);
}
- $r = q("SELECT `resource-id`, `id`, `filename`, min(`scale`) AS `hiq`,max(`scale`) AS `loq`, `desc`
+ $r = q("SELECT `resource-id`, `id`, `filename`, type, min(`scale`) AS `hiq`,max(`scale`) AS `loq`, `desc`
FROM `photo` WHERE `uid` = %d $sql_extra
GROUP BY `resource-id` $sql_extra2",
intval(local_user())
);
-
- function files1($rr){ global $a; return array( $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['hiq'] . '.jpg', template_escape($rr['filename']), $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['loq'] . '.jpg'); }
+ function files1($rr){
+ global $a;
+ $types = Photo::supportedTypes();
+ $ext = $types[$rr['type']];
+ return array(
+ $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['hiq'] . '.' .$ext,
+ template_escape($rr['filename']),
+ $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['loq'] . '.'. $ext
+ );
+ }
$files = array_map("files1", $r);
$tpl = get_markup_template("filebrowser.tpl");