Problem/Motivation

When the format of the picture is not jpg, an error occurs when using the covert JPG at image style.

Steps to reproduce

1. Create an image style using the 'Convert JPG' feature.
2. Create a content type with image upload fields(The 'File directory' is null)
3. Set the field display format to image & using the image style created by step 1.
4. Add new content of content type created by step 2, upload image of the format is not jpg.
5. View the node detail, the image is not broken.

Issue fork drupal-3202411

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

simbaw created an issue. See original summary.

simbaw’s picture

StatusFileSize
new9.44 KB
new10.64 KB
new1.05 KB

Root cause: This issue caused by the PHP function 'pathinfo()' parsing error.
Case 1: phthinfo('private://br_01_rev02_0_0.png.jpg') -> case1
Case 2: phthinfo('private://2021-02/BR_01_rev02_0.png.jpg') -> case2
The $converted_image_uri is:
Case 1: private:/br_01_rev02_0_0.png
Case 2: private://2021-02/BR_01_rev02_0.png

So we need set $converted_image_uri to correct in case1

simbaw’s picture

Status: Active » Needs review
Madhu kumar’s picture

This does not work if your default file scheme is private and you are trying to generate an image style for a public file.

simbaw’s picture

StatusFileSize
new1.09 KB

Hi Madhu,
Thanks for reminding me, I have updated the patch.

gauravvvv’s picture

I have attached after and before patch screenshots. Image other than the .jpg extension seems to be broken.

Madhu kumar’s picture

Patch #7 applied cleanly and it is working well.

simbaw’s picture

StatusFileSize
new13.51 KB
new1.57 KB

I found applying the patch of #7, the image will be broken on ie11. Because the content type in the response header is sometimes different from the image type, but in IE11, the response header and the image type need to be the same.
So I create a new patch for this.

Status: Needs review » Needs work

The last submitted patch, 10: 3202411-Image-convert-failed-10.patch, failed testing. View results

simbaw’s picture

Version: 8.9.x-dev » 9.1.x-dev
StatusFileSize
new1.88 KB
simbaw’s picture

Status: Needs work » Needs review
simbaw’s picture

StatusFileSize
new2.6 KB

The pathinfo can not support the Chinese. so I updated the patch.
https://www.php.net/manual/en/function.pathinfo.php

Version: 9.1.x-dev » 9.3.x-dev

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

connbi’s picture

StatusFileSize
new2.64 KB
Munavijayalakshmi’s picture

Assigned: Unassigned » Munavijayalakshmi
StatusFileSize
new2.72 KB

Rectify custom commands failed errors.

Status: Needs review » Needs work

The last submitted patch, 18: 3202411-Image-convert-failed-18.patch, failed testing. View results

Munavijayalakshmi’s picture

Assigned: Munavijayalakshmi » Unassigned

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

arakwar’s picture

Is this still an issue in Drupal 10.2 (and 11) ?

While trying to redo the patch for 10.2/11, I can see core changed and seems to be close to what the patch does, but for now I can be 100% sure of it.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.