@@ 1048-1103 (lines=56) @@ | ||
1045 | * @author Dmitry (dio) Levashov |
|
1046 | * @author Naoki Sawada |
|
1047 | **/ |
|
1048 | protected function createTmb($path, $stat) |
|
1049 | { |
|
1050 | if (! $stat || ! $this->canCreateTmb($path, $stat)) { |
|
1051 | return false; |
|
1052 | } |
|
1053 | ||
1054 | $name = $this->tmbname($stat); |
|
1055 | $tmb = $this->tmbPath.DIRECTORY_SEPARATOR.$name; |
|
1056 | ||
1057 | // copy image into tmbPath so some drivers does not store files on local fs |
|
1058 | if (! $data = $this->_bd_getThumbnail($path)) { |
|
1059 | return false; |
|
1060 | } |
|
1061 | if (! file_put_contents($tmb, $data)) { |
|
1062 | return false; |
|
1063 | } |
|
1064 | ||
1065 | $result = false; |
|
1066 | ||
1067 | $tmbSize = $this->tmbSize; |
|
1068 | ||
1069 | if (($s = getimagesize($tmb)) == false) { |
|
1070 | return false; |
|
1071 | } |
|
1072 | ||
1073 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
|
1074 | if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
1075 | $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
1076 | } else { |
|
1077 | if ($this->options['tmbCrop']) { |
|
1078 | ||
1079 | /* Resize and crop if image bigger than thumbnail */ |
|
1080 | if (! (($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
1081 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
|
1082 | } |
|
1083 | ||
1084 | if (($s = getimagesize($tmb)) != false) { |
|
1085 | $x = $s[0] > $tmbSize ? intval(($s[0] - $tmbSize) / 2) : 0; |
|
1086 | $y = $s[1] > $tmbSize ? intval(($s[1] - $tmbSize) / 2) : 0; |
|
1087 | $result = $this->imgCrop($tmb, $tmbSize, $tmbSize, $x, $y, 'png'); |
|
1088 | } |
|
1089 | } else { |
|
1090 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png'); |
|
1091 | } |
|
1092 | ||
1093 | $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
1094 | } |
|
1095 | ||
1096 | if (! $result) { |
|
1097 | unlink($tmb); |
|
1098 | ||
1099 | return false; |
|
1100 | } |
|
1101 | ||
1102 | return $name; |
|
1103 | } |
|
1104 | ||
1105 | /** |
|
1106 | * Return thumbnail file name for required file. |
@@ 791-846 (lines=56) @@ | ||
788 | * @author Dmitry (dio) Levashov |
|
789 | * @author Naoki Sawada |
|
790 | */ |
|
791 | protected function createTmb($path, $stat) |
|
792 | { |
|
793 | if (! $stat || ! $this->canCreateTmb($path, $stat)) { |
|
794 | return false; |
|
795 | } |
|
796 | ||
797 | $name = $this->tmbname($stat); |
|
798 | $tmb = $this->tmbPath.DIRECTORY_SEPARATOR.$name; |
|
799 | ||
800 | // copy image into tmbPath so some drivers does not store files on local fs |
|
801 | if (! $data = $this->getThumbnail($path, $this->options['getTmbSize'])) { |
|
802 | return false; |
|
803 | } |
|
804 | if (! file_put_contents($tmb, $data)) { |
|
805 | return false; |
|
806 | } |
|
807 | ||
808 | $result = false; |
|
809 | ||
810 | $tmbSize = $this->tmbSize; |
|
811 | ||
812 | if (($s = getimagesize($tmb)) == false) { |
|
813 | return false; |
|
814 | } |
|
815 | ||
816 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
|
817 | if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
818 | $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
819 | } else { |
|
820 | if ($this->options['tmbCrop']) { |
|
821 | ||
822 | /* Resize and crop if image bigger than thumbnail */ |
|
823 | if (! (($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
824 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
|
825 | } |
|
826 | ||
827 | if (($s = getimagesize($tmb)) != false) { |
|
828 | $x = $s[0] > $tmbSize ? intval(($s[0] - $tmbSize) / 2) : 0; |
|
829 | $y = $s[1] > $tmbSize ? intval(($s[1] - $tmbSize) / 2) : 0; |
|
830 | $result = $this->imgCrop($tmb, $tmbSize, $tmbSize, $x, $y, 'png'); |
|
831 | } |
|
832 | } else { |
|
833 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png'); |
|
834 | } |
|
835 | ||
836 | $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
837 | } |
|
838 | ||
839 | if (! $result) { |
|
840 | unlink($tmb); |
|
841 | ||
842 | return false; |
|
843 | } |
|
844 | ||
845 | return $name; |
|
846 | } |
|
847 | ||
848 | /** |
|
849 | * Return thumbnail file name for required file. |
@@ 794-849 (lines=56) @@ | ||
791 | * |
|
792 | * @author Naoki Sawada |
|
793 | **/ |
|
794 | protected function createTmb($path, $stat) |
|
795 | { |
|
796 | if (! $stat || ! $this->canCreateTmb($path, $stat)) { |
|
797 | return false; |
|
798 | } |
|
799 | ||
800 | $name = $this->tmbname($stat); |
|
801 | $tmb = $this->tmbPath.DIRECTORY_SEPARATOR.$name; |
|
802 | ||
803 | // copy image into tmbPath so some drivers does not store files on local fs |
|
804 | if (! $data = $this->_db_getThumbnail($path)) { |
|
805 | return false; |
|
806 | } |
|
807 | if (! file_put_contents($tmb, $data)) { |
|
808 | return false; |
|
809 | } |
|
810 | ||
811 | $result = false; |
|
812 | ||
813 | $tmbSize = $this->tmbSize; |
|
814 | ||
815 | if (($s = getimagesize($tmb)) == false) { |
|
816 | return false; |
|
817 | } |
|
818 | ||
819 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
|
820 | if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
821 | $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
822 | } else { |
|
823 | if ($this->options['tmbCrop']) { |
|
824 | ||
825 | /* Resize and crop if image bigger than thumbnail */ |
|
826 | if (! (($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
827 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
|
828 | } |
|
829 | ||
830 | if (($s = getimagesize($tmb)) != false) { |
|
831 | $x = $s[0] > $tmbSize ? intval(($s[0] - $tmbSize) / 2) : 0; |
|
832 | $y = $s[1] > $tmbSize ? intval(($s[1] - $tmbSize) / 2) : 0; |
|
833 | $result = $this->imgCrop($tmb, $tmbSize, $tmbSize, $x, $y, 'png'); |
|
834 | } |
|
835 | } else { |
|
836 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png'); |
|
837 | } |
|
838 | ||
839 | $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
840 | } |
|
841 | ||
842 | if (! $result) { |
|
843 | unlink($tmb); |
|
844 | ||
845 | return false; |
|
846 | } |
|
847 | ||
848 | return $name; |
|
849 | } |
|
850 | ||
851 | /** |
|
852 | * Return thumbnail file name for required file. |
@@ 1214-1269 (lines=56) @@ | ||
1211 | * @author Dmitry (dio) Levashov |
|
1212 | * @author Naoki Sawada |
|
1213 | **/ |
|
1214 | protected function createTmb($path, $stat) |
|
1215 | { |
|
1216 | if (! $stat || ! $this->canCreateTmb($path, $stat)) { |
|
1217 | return false; |
|
1218 | } |
|
1219 | ||
1220 | $name = $this->tmbname($stat); |
|
1221 | $tmb = $this->tmbPath.DIRECTORY_SEPARATOR.$name; |
|
1222 | ||
1223 | // copy image into tmbPath so some drivers does not store files on local fs |
|
1224 | if (! $data = $this->_gd_getThumbnail($path)) { |
|
1225 | return false; |
|
1226 | } |
|
1227 | if (! file_put_contents($tmb, $data)) { |
|
1228 | return false; |
|
1229 | } |
|
1230 | ||
1231 | $result = false; |
|
1232 | ||
1233 | $tmbSize = $this->tmbSize; |
|
1234 | ||
1235 | if (($s = getimagesize($tmb)) == false) { |
|
1236 | return false; |
|
1237 | } |
|
1238 | ||
1239 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
|
1240 | if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
1241 | $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
1242 | } else { |
|
1243 | if ($this->options['tmbCrop']) { |
|
1244 | ||
1245 | /* Resize and crop if image bigger than thumbnail */ |
|
1246 | if (! (($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
1247 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
|
1248 | } |
|
1249 | ||
1250 | if (($s = getimagesize($tmb)) != false) { |
|
1251 | $x = $s[0] > $tmbSize ? intval(($s[0] - $tmbSize) / 2) : 0; |
|
1252 | $y = $s[1] > $tmbSize ? intval(($s[1] - $tmbSize) / 2) : 0; |
|
1253 | $result = $this->imgCrop($tmb, $tmbSize, $tmbSize, $x, $y, 'png'); |
|
1254 | } |
|
1255 | } else { |
|
1256 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png'); |
|
1257 | } |
|
1258 | ||
1259 | $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
1260 | } |
|
1261 | ||
1262 | if (! $result) { |
|
1263 | unlink($tmb); |
|
1264 | ||
1265 | return false; |
|
1266 | } |
|
1267 | ||
1268 | return $name; |
|
1269 | } |
|
1270 | ||
1271 | /** |
|
1272 | * Return thumbnail file name for required file. |
@@ 984-1039 (lines=56) @@ | ||
981 | * @author Dmitry (dio) Levashov |
|
982 | * @author Naoki Sawada |
|
983 | **/ |
|
984 | protected function createTmb($path, $stat) |
|
985 | { |
|
986 | if (! $stat || ! $this->canCreateTmb($path, $stat)) { |
|
987 | return false; |
|
988 | } |
|
989 | ||
990 | $name = $this->tmbname($stat); |
|
991 | $tmb = $this->tmbPath.DIRECTORY_SEPARATOR.$name; |
|
992 | ||
993 | // copy image into tmbPath so some drivers does not store files on local fs |
|
994 | if (! $data = $this->_od_getThumbnail($path)) { |
|
995 | return false; |
|
996 | } |
|
997 | if (! file_put_contents($tmb, $data)) { |
|
998 | return false; |
|
999 | } |
|
1000 | ||
1001 | $result = false; |
|
1002 | ||
1003 | $tmbSize = $this->tmbSize; |
|
1004 | ||
1005 | if (($s = getimagesize($tmb)) == false) { |
|
1006 | return false; |
|
1007 | } |
|
1008 | ||
1009 | /* If image smaller or equal thumbnail size - just fitting to thumbnail square */ |
|
1010 | if ($s[0] <= $tmbSize && $s[1] <= $tmbSize) { |
|
1011 | $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
1012 | } else { |
|
1013 | if ($this->options['tmbCrop']) { |
|
1014 | ||
1015 | /* Resize and crop if image bigger than thumbnail */ |
|
1016 | if (! (($s[0] > $tmbSize && $s[1] <= $tmbSize) || ($s[0] <= $tmbSize && $s[1] > $tmbSize)) || ($s[0] > $tmbSize && $s[1] > $tmbSize)) { |
|
1017 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, false, 'png'); |
|
1018 | } |
|
1019 | ||
1020 | if (($s = getimagesize($tmb)) != false) { |
|
1021 | $x = $s[0] > $tmbSize ? intval(($s[0] - $tmbSize) / 2) : 0; |
|
1022 | $y = $s[1] > $tmbSize ? intval(($s[1] - $tmbSize) / 2) : 0; |
|
1023 | $result = $this->imgCrop($tmb, $tmbSize, $tmbSize, $x, $y, 'png'); |
|
1024 | } |
|
1025 | } else { |
|
1026 | $result = $this->imgResize($tmb, $tmbSize, $tmbSize, true, true, 'png'); |
|
1027 | } |
|
1028 | ||
1029 | $result = $this->imgSquareFit($tmb, $tmbSize, $tmbSize, 'center', 'middle', $this->options['tmbBgColor'], 'png'); |
|
1030 | } |
|
1031 | ||
1032 | if (! $result) { |
|
1033 | unlink($tmb); |
|
1034 | ||
1035 | return false; |
|
1036 | } |
|
1037 | ||
1038 | return $name; |
|
1039 | } |
|
1040 | ||
1041 | /** |
|
1042 | * Return thumbnail file name for required file. |