mirror of
https://github.com/HaschekSolutions/pictshare.git
synced 2025-11-11 18:56:21 +00:00
implemented gif2mp4 conversion and added display of max upload size on form
This commit is contained in:
@@ -23,16 +23,17 @@ Test site: https://dev.pictshare.net/ (only sometimes on)
|
||||
- [x] URL
|
||||
- [x] LOG_UPLOADER
|
||||
- [x] FFMPEG_BINARY
|
||||
- [ ] PNG_COMPRESSION
|
||||
- [ ] JPEG_COMPRESSION
|
||||
- [x] PNG_COMPRESSION
|
||||
- [x] JPEG_COMPRESSION
|
||||
- [x] WEBP_COMPRESSION
|
||||
- [ ] MASTER_DELETE_CODE
|
||||
- [ ] MASTER_DELETE_IP
|
||||
- [ ] UPLOAD_CODE
|
||||
|
||||
### Image hosting
|
||||
- [ ] Resizing
|
||||
- [X] Resizing
|
||||
- [ ] Filters
|
||||
- [ ] Gif to mp4 conversion
|
||||
- [x] Gif to mp4 conversion
|
||||
- [x] Upload of images
|
||||
|
||||
### Text file hosting
|
||||
|
||||
@@ -126,7 +126,44 @@ class ImageController implements ContentController
|
||||
break;
|
||||
|
||||
case 'mp4':
|
||||
$mp4path = ROOT.DS.'data'.DS.$hash.DS.$hash.'mp4';
|
||||
if(!file_exists($mp4path))
|
||||
$this->gifToMP4($path,$mp4path);
|
||||
$path = $mp4path;
|
||||
|
||||
if(in_array('raw',$url))
|
||||
(new VideoController())->serveMP4($path,$hash);
|
||||
else if(in_array('preview',$url))
|
||||
{
|
||||
$preview = $path.'_preview.jpg';
|
||||
if(!file_exists($preview))
|
||||
{
|
||||
(new VideoController())->saveFirstFrameOfMP4($path,$preview);
|
||||
}
|
||||
|
||||
header ("Content-type: image/jpeg");
|
||||
readfile($preview);
|
||||
|
||||
}
|
||||
else if(in_array('download',$url))
|
||||
{
|
||||
if (file_exists($path)) {
|
||||
header('Content-Description: File Transfer');
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename="'.basename($path).'"');
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: ' . filesize($path));
|
||||
readfile($path);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = array('url'=>implode('/',$url),'hash'=>$hash,'filesize'=>renderSize(filesize($path)));
|
||||
renderTemplate('video',$data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -168,6 +205,20 @@ class ImageController implements ContentController
|
||||
return imagecreatefromstring(file_get_contents($path));
|
||||
}
|
||||
|
||||
function gifToMP4($gifpath,$target)
|
||||
{
|
||||
$bin = escapeshellcmd(FFMPEG_BINARY);
|
||||
$file = escapeshellarg($gifpath);
|
||||
|
||||
if(!file_exists($target)) //simple caching.. have to think of something better
|
||||
{
|
||||
$cmd = "$bin -f gif -y -i $file -vcodec libx264 -an -profile:v baseline -level 3.0 -pix_fmt yuv420p -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" -f mp4 $target";
|
||||
system($cmd);
|
||||
}
|
||||
|
||||
return $target;
|
||||
}
|
||||
|
||||
function saveObjOfImage($im,$path,$type)
|
||||
{
|
||||
switch($type)
|
||||
|
||||
@@ -40,6 +40,9 @@
|
||||
<h4><?php echo $slogan; ?></h4>
|
||||
<div class="well">
|
||||
<div id="uploadinfo"></div>
|
||||
<?php
|
||||
echo "Max Upload size: ". (int)(ini_get('upload_max_filesize'))."MB / File";
|
||||
?>
|
||||
<form class="dropzone well" id="dropzone" method="post" action="/api/upload.php" enctype="multipart/form-data">
|
||||
<div class="fallback">
|
||||
<input name="file" type="file" multiple />
|
||||
|
||||
Reference in New Issue
Block a user