Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added mov and webp support #30

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions wwwroot/notgallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function the($Thing)
$Path = pathinfo($Thing);
$Extension = $Path['extension'];

if(preg_match('{jpe?g|gif|png}i', $Extension))
if(preg_match('{jpe?g|gif|png|webp}i', $Extension))
return 'Image';
}

Expand Down Expand Up @@ -62,9 +62,11 @@ function ResizeImage($Filename, $Thumbnail, $Size)
case "image/jpeg":
$Image = @ImageCreateFromJpeg($Filename);
break;
case "image/webp":
$Image = @ImageCreateFromWebp($Filename);
}

if($ImageData[2] == IMAGETYPE_GIF or $ImageData[2] == IMAGETYPE_PNG)
if($ImageData[2] == IMAGETYPE_GIF or $ImageData[2] == IMAGETYPE_PNG or $ImageData[2] == IMAGETYPE_WEBP)
{
$TransIndex = imagecolortransparent($Image);

Expand All @@ -85,7 +87,7 @@ function ResizeImage($Filename, $Thumbnail, $Size)

}
// Always make a transparent background color for PNGs that don't have one allocated already
elseif ($ImageData[2] == IMAGETYPE_PNG)
elseif ($ImageData[2] == IMAGETYPE_PNG or $ImageData[2] == IMAGETYPE_WEBP)
{

// Turn off transparency blending (temporarily)
Expand All @@ -111,6 +113,9 @@ function ResizeImage($Filename, $Thumbnail, $Size)
case "image/png":
@ImagePng($NewImage, $Thumbnail);
break;
case "image/webp":
@ImageWebp($NewImage, $Thumbnail);
break;
case "image/jpeg":
@ImageJpeg($NewImage, $Thumbnail);
break;
Expand Down
7 changes: 7 additions & 0 deletions wwwroot/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function uuid($prefix = '')
else
{
$Mime = mime_content_type($Image['tmp_name']);
error_log($Mime);
switch($Mime){
case "image/jpg":
$Extension = "jpg";
Expand All @@ -39,6 +40,9 @@ function uuid($prefix = '')
case "image/png":
$Extension = "png";
break;
case "image/webp":
$Extension = "webp";
break;
case "audio/mpeg":
case "audio/mp3":
$Extension = "mp3";
Expand All @@ -50,6 +54,9 @@ function uuid($prefix = '')
case "video/mp4":
$Extension = "mp4";
break;
case "video/quicktime":
$Extension = "mov";
break;
case "audio/midi":
case "audio/xmidi":
$Extension = "mid";
Expand Down