"ext-sodium": "*",
"laravel/framework": "~5.8|^6.0|^7.0|^8.0",
"cubist/net": "dev-master",
- "dpb587/microdata-dom": "dev-master"
+ "dpb587/microdata-dom": "dev-master",
+ "cubist/pdf": "dev-master"
}
}
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "93cb873c086aa9bc665faf4289e64fce",
+ "content-hash": "f353439092103527932eadf9bc1faa09",
"packages": [
{
"name": "brick/math",
"description": "net cubist composer package",
"time": "2023-01-27T14:43:25+00:00"
},
+ {
+ "name": "cubist/pdf",
+ "version": "dev-master",
+ "source": {
+ "type": "git",
+ "url": "git://git.cubedesigners.com/cubist_pdf.git",
+ "reference": "97b5e96140945c11230ab5dc48219e30d8a6f3c2"
+ },
+ "dist": {
+ "type": "tar",
+ "url": "https://composer.cubedesigners.com/dist/cubist/pdf/cubist-pdf-dev-master-426fa1.tar",
+ "reference": "97b5e96140945c11230ab5dc48219e30d8a6f3c2",
+ "shasum": "2313cfd88752a2ef63f0a94ef27bf636c488ff1c"
+ },
+ "require": {
+ "cubist/util": "dev-master",
+ "ext-dom": "*",
+ "ext-json": "*",
+ "ext-libxml": "*",
+ "laravel/framework": "~5.8|^6.0|^7.0|^8.0",
+ "php": ">=7.4"
+ },
+ "default-branch": true,
+ "type": "library",
+ "extra": {
+ "laravel": {
+ "providers": []
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Cubist\\PDF\\": "src"
+ }
+ },
+ "license": [
+ "proprietary"
+ ],
+ "authors": [
+ {
+ "name": "Vincent Vanwaelscappel",
+ "email": "vincent@cubedesigners.com"
+ }
+ ],
+ "description": "PDF",
+ "keywords": [
+ "cubist",
+ "pdf"
+ ],
+ "time": "2023-03-02T16:43:11+00:00"
+ },
{
"name": "dflydev/dot-access-data",
"version": "dev-main",
"minimum-stability": "dev",
"stability-flags": {
"cubist/net": 20,
- "dpb587/microdata-dom": 20
+ "dpb587/microdata-dom": 20,
+ "cubist/pdf": 20
},
"prefer-stable": false,
"prefer-lowest": false,
namespace Cubist\Util\Graphics;
+use Cubist\PDF\PDFTools;
use Cubist\Util\Animations\OAMAnimation;
use Cubist\Util\Animations\ZipAnimation;
use Cubist\Util\Files\Files;
throw new \Exception('File ' . $path . ' does not exist');
}
- $allowedExtensions = ['svg', 'oam', 'zip', 'jpeg', 'jpg', 'gif', 'png', 'webm'];
+ $allowedExtensions = ['svg', 'oam', 'zip', 'jpeg', 'jpg', 'gif', 'png', 'webm', 'pdf'];
$ext = Files::getExtension($path);
if (!in_array($ext, $allowedExtensions)) {
throw new \Exception('File ' . $path . ' is not a valid image');
}
- if ($ext === 'svg') {
+ if ($ext === 'pdf') {
+ $i = PDFTools::infos($path);
+ $res = $i['infos']['size'];
+ } else if ($ext === 'svg') {
$svg = simplexml_load_string(file_get_contents($path));
$attr = $svg->attributes();
if (!isset($attr['width']) || !isset($attr['height'])) {
return $color;
}
+ public static function keepRatio($naturalWidth, $naturalHeight, $forcedWidth = null, $forcedHeight = null, $contains = true)
+ {
+ $w = $naturalWidth;
+ $h = $naturalHeight;
+ if (!$forcedHeight && !$forcedWidth) {
+ return [$w, $h];
+ }
+
+ $ratio = $naturalWidth / $naturalHeight;
+ if (!$forcedWidth) {
+ $forcedWidth = $naturalWidth;
+ }
+ if (!$forcedHeight) {
+ $forcedHeight = $naturalHeight;
+ }
+ $s1 = $forcedWidth / $naturalWidth;
+ $s2 = $forcedHeight / $naturalHeight;
+ if ($contains) {
+ $scale = min($s1, $s2);
+ } else {
+ $scale = max($s1, $s2);
+ }
+ $w = $naturalWidth * $scale;
+ $h = $naturalHeight * $scale;
+ return [$w, $h];
+ }
+
}