@@ -1525,22 +1525,23 @@ public function save($folder, $imageName, $createFolders = true, $backgroundColo
1525
1525
throw new ImageWorkshopLayerException (sprintf ('Destination folder "%s" not writable. ' , $ folder ), self ::ERROR_NOT_WRITABLE_FOLDER );
1526
1526
}
1527
1527
1528
+ $ extension = explode ('. ' , $ imageName );
1529
+ $ extension = strtolower ($ extension [count ($ extension ) - 1 ]);
1530
+
1531
+ $ filename = sprintf ('%s/%s ' , rtrim ($ folder , '/ ' ), ltrim ($ imageName , '/ ' ));
1532
+
1528
1533
// Creating the folders if they don't exist
1529
- if (!is_dir ($ folder ) && $ createFolders ) {
1530
- if (!mkdir ($ folder , 0777 , true )) {
1531
- throw new ImageWorkshopLayerException (sprintf ('Unable to create destination folder "%s". ' , $ folder ), self ::ERROR_NOT_WRITABLE_FOLDER );
1534
+ $ dirname = dirname ($ filename );
1535
+ if (!is_dir ($ dirname ) && $ createFolders ) {
1536
+ if (!mkdir ($ dirname , 0777 , true )) {
1537
+ throw new ImageWorkshopLayerException (sprintf ('Unable to create destination folder "%s". ' , $ dirname ), self ::ERROR_NOT_WRITABLE_FOLDER );
1532
1538
}
1533
1539
1534
1540
$ oldUmask = umask (0 );
1535
1541
umask ($ oldUmask );
1536
- chmod ($ folder , 0777 );
1542
+ chmod ($ dirname , 0777 );
1537
1543
}
1538
1544
1539
- $ extension = explode ('. ' , $ imageName );
1540
- $ extension = strtolower ($ extension [count ($ extension ) - 1 ]);
1541
-
1542
- $ filename = $ folder .'/ ' .$ imageName ;
1543
-
1544
1545
if (($ extension == 'jpg ' || $ extension == 'jpeg ' || $ extension == 'gif ' ) && (!$ backgroundColor || $ backgroundColor == 'transparent ' )) {
1545
1546
$ backgroundColor = 'ffffff ' ;
1546
1547
}
0 commit comments