Hi there,
I’m encountering an issue when trying to convert a product image from PNG to JPEG. When using the fileUpdate mutation, I receive the following error:
INVALID_FILENAME_EXTENSION
The filename extension provided must match the original filename.
From my understanding, it seems that Shopify enforces the filename extension to remain consistent with the original file.
Is there any way to directly update a product image and convert it from PNG to JPEG using the API?
If not, do I need to perform the following steps to achieve this:
- Add the new staged upload for the JPEG image.
- Attach the JPEG image to the product.
- Reorder the images.
- Assign the new image to the appropriate variants.
- Delete the previous PNG image.
If this is the only solution, could anyone confirm if the above workflow is correct, or suggest improvements?
Thank you in advance for your help!
Hi
As you noticed, Shopify’s fileUpdate
mutation enforces that the filename extension of the updated file matches the original file. This means you cannot directly convert a product image from PNG to JPEG using this mutation due to the INVALID_FILENAME_EXTENSION
error.
The workaround that might apply to you could be:
- Use the
fileCreate
mutation to upload the new JPEG image.
- Use the
productCreateMedia
mutation to attach the uploaded JPEG image to the product.
- (optional) Use the
productUpdateMedia
mutation to reorder the images if necessary.
- Finally, use the
fileDelete
mutation to delete the old PNG image.
Hope this helps!
Thank you for your response and the detailed workaround! I appreciate the effort in providing guidance. However, I noticed that the methods mentioned, such as productCreateMedia
and productUpdateMedia
, are marked as deprecated in the Shopify GraphQL API.
We’re currently transitioning from REST to GraphQL, and the process is already overwhelming with all the necessary changes. Using deprecated methods adds an additional layer of complexity, as we might need to rework our implementation again once these are fully removed.
I also noticed that these same deprecated mutations have been recommended in your replies to other threads, even when they were already marked as deprecated at the time. This adds to the confusion, as we’re unsure whether to proceed with these methods or search for alternative approaches to avoid rework in the future.
This leads me to a couple of questions:
- Is there a recommended non-deprecated approach to achieve the PNG-to-JPEG image update?
- Regarding deprecated mutations and fields, is there a specific timeline for their removal?
For example:
- Are they removed after a particular date announced in advance?
- Or is it safe to rely on them for a specific period after deprecation?
Understanding this would greatly help us plan our implementation and avoid the confusion of switching to methods that may soon be unavailable.
Thank you again for your help and clarification!
Your following steps you listed I think would be correct. Similar uploading of images has been discussed here, without using deprecated calls How to upload a product image with GraphQL? - #2 by JordanFinners