Deltacms/core/vendor/screenshot/screenshot.php

34 lines
986 B
PHP
Raw Normal View History

2022-01-31 09:10:49 +01:00
<?php
if (isset($_POST['image'])) {
$data = $_POST['image'] ;
2022-05-30 09:05:11 +02:00
$data = str_replace(' ','+',$data);
$data = str_replace('data:image/png;base64,', '', $data);
2022-01-31 09:10:49 +01:00
$img = base64_decode($data);
// Effacer l'image et la miniature jpg
2022-05-30 09:05:11 +02:00
if (file_exists('../../../site/file/thumb/screenshot.jpg')) {
chmod('../../../site/file/thumb/screenshot.jpg', 0777);
unlink ('../../../site/file/thumb/screenshot.jpg');
2022-01-31 09:10:49 +01:00
}
2022-05-30 09:05:11 +02:00
if (file_exists('../../../site/file/source/screenshot.jpg')) {
chmod('../../../site/file/source/screenshot.jpg', 0777);
unlink ('../../../site/file/source/screenshot.jpg');
2022-01-31 09:10:49 +01:00
}
2022-05-30 09:05:11 +02:00
file_put_contents('screenshot.png',$img) ;
2022-01-31 09:10:49 +01:00
2022-05-30 09:05:11 +02:00
$image = imagecreatefrompng('screenshot.png');
2022-01-31 09:10:49 +01:00
$quality = 75;
2022-05-30 09:05:11 +02:00
imagejpeg($image, '../../../site/file/source/screenshot.jpg', $quality);
if (file_exists('screenshot.png')) {
chmod('screenshot.png', 0777);
unlink ('screenshot.png');
2022-01-31 09:10:49 +01:00
}
2022-05-30 09:05:11 +02:00
2022-01-31 09:10:49 +01:00
imagedestroy($image);
}
?>