File tree Expand file tree Collapse file tree 1 file changed +2
-8
lines changed Expand file tree Collapse file tree 1 file changed +2
-8
lines changed Original file line number Diff line number Diff line change @@ -56,15 +56,9 @@ export const compressImage = ({
5656 // Change the file.name & file.type for converting file type
5757 const targetFileType = outputFormat === 'preserve' ? imageFile . type : `image/${ outputFormat } ` ;
5858 const targetSubtype = targetFileType . split ( '/' ) . pop ( ) ;
59- let targetName = '' ;
6059 const dotIndex = imageFile . name . lastIndexOf ( '.' ) ;
61- if ( dotIndex === - 1 ) {
62- // No extension found, use the original filename
63- targetName = imageFile . name ;
64- } else {
65- // Replace the old extension with the new one
66- targetName = imageFile . name . substring ( 0 , dotIndex ) + '.' + targetSubtype ;
67- }
60+ // targetName = `fileName.targetSubtype`
61+ const targetName = `${ dotIndex === - 1 ? imageFile . name : imageFile . name . substring ( 0 , dotIndex ) } .${ targetSubtype } ` ;
6862 ctx . canvas . toBlob (
6963 ( blob ) => {
7064 if ( blob ) {
You can’t perform that action at this time.
0 commit comments