Compare commits

...

2 Commits

2 changed files with 19 additions and 7 deletions

View File

@ -84,7 +84,7 @@
<div class="col-md-3">
<div class="card bg-light">
<div class="card-body text-center">
<h6>Total Items Registered</h6>
<h6>Total Products Registered</h6>
<h3>{{ reportData.itemCountRegistered }}</h3>
</div>
</div>

View File

@ -1358,16 +1358,28 @@ namespace PSTW_CentralSystem.Controllers.API.Inventory
}
private bool IsImage(byte[] bytes)
{
// JPEG file signature: FF D8 FF
if (bytes.Length > 2 && bytes[0] == 0xFF && bytes[1] == 0xD8 && bytes[2] == 0xFF)
if (bytes.Length < 4) return false;
// JPEG: Starts with FF D8
if (bytes[0] == 0xFF && bytes[1] == 0xD8)
return true;
// PNG file signature: 89 50 4E 47 0D 0A 1A 0A
if (bytes.Length > 7 && bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47)
// PNG: 89 50 4E 47
if (bytes[0] == 0x89 && bytes[1] == 0x50 && bytes[2] == 0x4E && bytes[3] == 0x47)
return true;
// GIF file signature: GIF87a or GIF89a
if (bytes.Length > 5 && bytes[0] == 0x47 && bytes[1] == 0x49 && bytes[2] == 0x46)
// GIF: GIF8
if (bytes[0] == 0x47 && bytes[1] == 0x49 && bytes[2] == 0x46)
return true;
// WebP: Starts with 'RIFF' and has 'WEBP' at offset 8
if (bytes.Length > 12 &&
bytes[0] == 0x52 && bytes[1] == 0x49 && bytes[2] == 0x46 && bytes[3] == 0x46 && // RIFF
bytes[8] == 0x57 && bytes[9] == 0x45 && bytes[10] == 0x42 && bytes[11] == 0x50) // WEBP
return true;
// HEIC (iPhone): Look for 'ftypheic' or 'ftypmif1'
if (bytes.Length > 12 && bytes[4] == 0x66 && bytes[5] == 0x74 && bytes[6] == 0x79 && bytes[7] == 0x70)
return true;
return false;