System library image php

Содержание
  1. OpenCart — изображения одинакового размера
  2. [SOLVED] Image.php [HELP]
  3. Адаптивный resize изображений [решено]
  4. Создайте аккаунт или войдите в него для комментирования
  5. Создать аккаунт
  6. Войти
  7. Похожие публикации
  8. Storm — универсальный адаптивный шаблон
  9. Focus — универсальный адаптивный шаблон
  10. Poster — универсальный адаптивный шаблон
  11. Avior — универсальный адаптивный шаблон
  12. Colibri — универсальный адаптивный шаблон
  13. Сейчас на странице 0 пользователей
  14. Покупателям
  15. Разработчикам
  16. Полезная информация
  17. Последние дополнения
  18. Меню покупок/Продаж
  19. OpenCart Русская Сборка
  20. Шаблоны
  21. OpenCart.Pro
  22. Важная информация
  23. Invalid image dimensions in image.php on line 105
  24. Re: Invalid image dimensions in image.php on line 105
  25. Re: Invalid image dimensions in image.php on line 105
  26. Re: Invalid image dimensions in image.php on line 105
  27. Re: Invalid image dimensions in image.php on line 105
  28. Re: Invalid image dimensions in image.php on line 105
  29. Re: Invalid image dimensions in image.php on line 105
  30. Re: Invalid image dimensions in image.php on line 105
  31. Re: Invalid image dimensions in image.php on line 105
  32. Re: Invalid image dimensions in image.php on line 105

OpenCart — изображения одинакового размера

Однажды я столкнулся с вопросом вывода изображений одинакового размера, но т.к. фотографии оказались то горизонтальными, то вертикальными — это немного осложнило задачу. Впрочем, не на много (:

И чтобы не изобретать велосипед, я полез на просторы интернета и нашел решение (Автор: shishifr1 с opencartforum.ru, по-крайней мере, это был его пост).

1) идем в /catalog/models/tool/image.php и вставляем функцию:

public function myresize($filename, $width, $height) < if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) < return; >$info = pathinfo($filename); $extension = $info['extension']; $old_image = $filename; $new_image = 'cache/' . substr($filename, 0, strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension; if (!file_exists(DIR_IMAGE . $new_image) || (filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image))) < $path = ''; $directories = explode('/', dirname(str_replace('../', '', $new_image))); foreach ($directories as $directory) < $path = $path . '/' . $directory; if (!file_exists(DIR_IMAGE . $path)) < @mkdir(DIR_IMAGE . $path, 0777); >> $image = new Image(DIR_IMAGE . $old_image); $image->myresize($width, $height); $image->save(DIR_IMAGE . $new_image); > if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) < return HTTPS_IMAGE . $new_image; >else < return HTTP_IMAGE . $new_image; >>

2) Далее открываем файл /system/library/image.php и добавляем:

public function myresize($width = 0, $height = 0) < if (!$this->info['width'] || !$this->info['height']) < return; >$x = $this->info['width']; $y = $this->info['height']; // old images width will fit if(($x / $y) < ($width/$height))< $scale = $width/$x; $newX = 0; $newY = - ($scale * $y - $height) / 2; // else old image's height will fit >else < $scale = $height/$y; $newX = - ($scale * $x - $width) / 2; $newY = 0; >$image_old = $this->image; $this->image = imagecreatetruecolor($width, $height); $new_width = $scale * $x; $new_height = $scale * $y; // now use imagecopyresampled imagecopyresampled($this->image, $image_old, $newX, $newY, 0, 0, $new_width, $new_height, $x, $y); if (isset($this->info['mime']) && $this->info['mime'] == 'image/png') < imagealphablending($this->image, false); imagesavealpha($this->image, true); $background = imagecolorallocatealpha($this->image, 255, 255, 255, 127); imagecolortransparent($this->image, $background); > else < $background = imagecolorallocate($this->image, 255, 255, 255); > imagedestroy($image_old); $this->info['width'] = $width; $this->info['height'] = $height; >

3) Теперь можем «ресайзить» изображения или стандартной функцией или приведенной выше. Для этого в контроллере (например, в категориях /catalog/controller/product/category.php) нужно найти

Читайте также:  All array functions in java

if ($result[‘image’]) < $image = $this->model_tool_image->resize($result[‘image’], $this->config->get(‘config_image_product_width’), $this->config->get(‘config_image_product_height’)); > else

и заменяем функцию с resize на myresize:

$image = $this->model_tool_image->myresize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));

PS: если у вас установлен FilterPro или что-то похожее, то нужно в контроллере фильтра в функции получения товара проделать пункт 3)

Вот и все! Теперь картинки будут обрезаться под один размер и заполнять все пространство!

Источник

[SOLVED] Image.php [HELP]

While browsing product page for a newly added product this warning message is showing ..
Well i am not a master programmer .. i tried to hide the message by error_reporting(0); on the head section of header.tpl .. but not working ..

Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /home/vastechc/public_html/shop/system/library/image.php on line 34Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: ‘/home/vastechc/public_html/shop/image/watermark.png’ is not a valid JPEG file in /home/vastechc/public_html/shop/system/library/image.php on line 34Warning: imagesx(): supplied argument is not a valid Image resource in /home/vastechc/public_html/shop/system/library/image.php on line 97Warning: imagesy(): supplied argument is not a valid Image resource in /home/vastechc/public_html/shop/system/library/image.php on line 98Notice: Undefined variable: watermark_pos_x in /home/vastechc/public_html/shop/system/library/image.php on line 119Notice: Undefined variable: watermark_pos_y in /home/vastechc/public_html/shop/system/library/image.php on line 119Warning: imagecopy(): supplied argument is not a valid Image resource in /home/vastechc/public_html/shop/system/library/image.php on line 119Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/vastechc/public_html/shop/system/library/image.php on line 121Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /home/vastechc/public_html/shop/system/library/image.php on line 34Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: ‘/home/vastechc/public_html/shop/image/watermark.png’ is not a valid JPEG file in /home/vastechc/public_html/shop/system/library/image.php on line 34Warning: imagesx(): supplied argument is not a valid Image resource in /home/vastechc/public_html/shop/system/library/image.php on line 97Warning: imagesy(): supplied argument is not a valid Image resource in /home/vastechc/public_html/shop/system/library/image.php on line 98Notice: Undefined variable: watermark_pos_x in /home/vastechc/public_html/shop/system/library/image.php on line 119Notice: Undefined variable: watermark_pos_y in /home/vastechc/public_html/shop/system/library/image.php on line 119Warning: imagecopy(): supplied argument is not a valid Image resource in /home/vastechc/public_html/shop/system/library/image.php on line 119Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/vastechc/public_html/shop/system/library/image.php on line 121

Источник

Адаптивный resize изображений [решено]

Создайте аккаунт или войдите в него для комментирования

Вы должны быть пользователем, чтобы оставить комментарий

Создать аккаунт

Зарегистрируйтесь для получения аккаунта. Это просто!

Войти

Уже зарегистрированы? Войдите здесь.

Похожие публикации

Storm — универсальный адаптивный шаблон

Focus — универсальный адаптивный шаблон

Poster — универсальный адаптивный шаблон

Avior — универсальный адаптивный шаблон

Colibri — универсальный адаптивный шаблон

Сейчас на странице 0 пользователей

Покупателям

Разработчикам

Полезная информация

Последние дополнения

Русская сборка OpenCart (OpenCart Русская Сборка) — официальный сайт OpenCartForum.com Powered by Invision Community

Меню покупок/Продаж

OpenCart Русская Сборка

Шаблоны

OpenCart.Pro

Важная информация

На нашем сайте используются файлы cookie и происходит обработка некоторых персональных данных пользователей, чтобы улучшить пользовательский интерфейс. Чтобы узнать для чего и какие персональные данные мы обрабатываем перейдите по ссылке. Если Вы нажмете «Я даю согласие», это означает, что Вы понимаете и принимаете все условия, указанные в этом Уведомлении о Конфиденциальности.

Читайте также:  (.*)

.sale_block_img<>.sale_block_img .sale_block_img_grid<>.sale_block_img .sale_block_img_grid ul.sale_block_img .sale_block_img_grid ul li.sale_block_img .sale_block_img_grid ul li img

Источник

Invalid image dimensions in image.php on line 105

Product images are not appearing in categories, and many PHP errors are appearing at the top of the page. Interesting to note, the product image URLs are broken in an unusual way. In the following HTML output (cut for size), the filename is missing the height portion of the file name (see correct file in bold).

Checking the filesystem, the correct image file is filename-228×228.png.

On the top of the page output:

Warning: imagecreatetruecolor(): Invalid image dimensions in /html/store/system/library/image.php on line 105Warning: imagealphablending() expects parameter 1 to be resource, boolean given in /html/store/system/library/image.php on line 108Warning: imagesavealpha() expects parameter 1 to be resource, boolean given in /html/store/system/library/image.php on line 109 . plus many more
2016-03-07 1:02:26 - PHP Warning: imagecreatetruecolor(): Invalid image dimensions in /html/store/system/library/image.php on line 105 2016-03-07 1:02:26 - PHP Warning: imagealphablending() expects parameter 1 to be resource, boolean given in /html/store/system/library/image.php on line 108 2016-03-07 1:02:26 - PHP Warning: imagesavealpha() expects parameter 1 to be resource, boolean given in /html/store/system/library/image.php on line 109 . and again, many more

Re: Invalid image dimensions in image.php on line 105

Post by gnurob » Tue Mar 08, 2016 8:41 pm

I can’t find the source of this bug. Is anyone else experiencing this issue? . does OpenCart require thumbnails to be resized before upload? . or maybe there is a required PHP library that is not installed, and not generating an error?

Re: Invalid image dimensions in image.php on line 105

Post by gnurob » Wed Mar 09, 2016 9:36 am

System, Users, User Groups, Administrator: grant permission to access and modify the theme

Extensions, Themes, click edit, then save.

No idea why this would come out of the box like this.

Re: Invalid image dimensions in image.php on line 105

Post by opencartboost » Wed Mar 09, 2016 2:59 pm

Can you show code for resize image at file controller?
Please note :
Opencart 2.2.0.0 have different code with older version for image resize, example
code for 2.2.0.0 like this :

$image = $this->model_tool_image->resize($result['image'], $this->config->get($this->config->get('config_theme') . '_image_product_width'), $this->config->get($this->config->get('config_theme') . '_image_product_height')); 
$image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')); 

Re: Invalid image dimensions in image.php on line 105

Post by pm-netti » Wed Mar 09, 2016 3:52 pm

gnurob wrote: I can’t find the source of this bug. Is anyone else experiencing this issue? . does OpenCart require thumbnails to be resized before upload? . or maybe there is a required PHP library that is not installed, and not generating an error?

Читайте также:  Reverse string in PHP without using string function PHP

Are you install images width & height?

Ps. This it is theme autors new jobs. Theme authors need create theme setting files admin/controller/theme/theme_xxxx.php, admin/view/template/theme/theme_xxxx.tpl and admin/language/*/theme/theme_xxx.php

Ps 2: My test this is not can change theme. This line 60 in file loader.php add automaticilly prefix ‘default/template/’:

$result = $this->registry->get('event')->trigger('view/' . $route . '/before', array(&$route, &$data));

Re: Invalid image dimensions in image.php on line 105

Post by pm-netti » Wed Mar 09, 2016 7:12 pm

$template = str_replace('default','peku',$template); return $this->adaptor->render($template);

Re: Invalid image dimensions in image.php on line 105

Post by Daniel » Wed Mar 09, 2016 11:57 pm

what about when you go to admin > extension > theme > Default Store Theme

then set the field Theme Directory to the name of the custom theme?

OpenCart®
Project Owner & Developer.

Re: Invalid image dimensions in image.php on line 105

Post by pm-netti » Thu Mar 10, 2016 12:21 am

Daniel wrote: what about when you go to admin > extension > theme > Default Store Theme

then set the field Theme Directory to the name of the custom theme?

Thanks! This is work!
Here it is possible to add your own theme configuration files, but they are not yet able to use

Re: Invalid image dimensions in image.php on line 105

Post by qahar » Sun Mar 13, 2016 12:50 am

As a note, this dimension image issue also happen when theme you choose at system > setting have status disabled on extensions > themes.

So make sure to never disabled your active theme.

Re: Invalid image dimensions in image.php on line 105

Post by macparts » Wed Oct 26, 2016 2:11 pm

Did anyone find a solution to this problem?

I have the same error. When I click on a top category I get these errors on top of the page

Warning: imagecreatetruecolor(): Invalid image dimensions in /home/macparts/public_html/ocn/system/library/image.php on line 105Warning: imagealphablending() expects parameter 1 to be resource, boolean given in /home/macparts/public_html/ocn/system/library/image.php on line 108Warning: imagesavealpha() expects parameter 1 to be resource, boolean given in /home/macparts/public_html/ocn/system/library/image.php on line 109Warning: imagecolorallocatealpha() expects parameter 1 to be resource, boolean given in /home/macparts/public_html/ocn/system/library/image.php on line 110Warning: imagecolortransparent() expects parameter 1 to be resource, boolean given in /home/macparts/public_html/ocn/system/library/image.php on line 111Warning: imagefilledrectangle() expects parameter 1 to be resource, boolean given in /home/macparts/public_html/ocn/system/library/image.php on line 116Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in /home/macparts/public_html/ocn/system/library/image.php on line 118

I have OC 2.2.0.0 and vqmod 2.5.1

Источник

Оцените статью