Editing a GIF, BMP, ICO or SVG writes PNG bytes under the original name
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 50/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- frontend
Línea de trabajo
Empieza en images.ts:94 y lib/components/ImageEditor.vue:46, y luego sigue onSave a través de ExportResult y props.file.encodedSource. Confirma el comportamiento para los tipos MIME indicados antes de decidir si los formatos no compatibles deben perder la edición o guardarse con un nuevo nombre coincidente. Se considera terminado cuando las ediciones no pueden escribir bytes incompatibles con el nombre original y se conserva la correspondencia de calidad de JPEG/WebP.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
images.ts:94 sets canEdit: true for the whole image handler, so the Edit button is offered on all 13 mimes it registers: image/apng, image/bmp, image/gif, image/jpeg, image/png, image/svg+xml, image/webp, image/x-icon, and image/heic, image/heif, image/tiff, image/x-xbitmap, image/emf where the server generates previews for them.
@nextcloud/image-editor can only write three. ExportOptions.format is typed 'image/png' | 'image/jpeg' | 'image/webp', and the viewer narrows it further at lib/components/ImageEditor.vue:46:
const exportOptions = computed<ExportOptions>(() => {
if (props.file.mime === 'image/jpeg' || props.file.mime === 'image/webp') {
return { format: props.file.mime, quality: 0.9 }
}
return { format: 'image/png' }
})
So editing a GIF produces PNG bytes, and onSave PUTs them to props.file.encodedSource, which is the original name. holiday.gif afterwards contains a PNG. Same for BMP, ICO, APNG (which loses its animation on the way through the canvas), TIFF, HEIC and, worst of the set, SVG, where a vector file comes back as a raster one under a .svg name.
ExportResult already carries mimeType, and the save path ignores it.
[!NOTE]
I have read this off the code path rather than reproduced it against a server, so the exact behaviour per mime is worth confirming before picking a fix.
Roughly, the options are to stop offering the edit where the format cannot be written back (narrow canEdit to the three, or make it per-mime rather than per-handler), or to save under a new name with the extension that matches what was actually encoded and leave the original alone. The second keeps the feature for more files but turns a save into a create, which the user should be told about rather than discover.
Second thing, same lines. The quality: 0.9 above overrides the quality matching in the editor's export. Left alone, qualityFor(source) reads the source's own quantization tables and writes the new file at the quality the old one was written at, held between 0.75 and 0.97. Passing an explicit 0.9 defeats that for every JPEG and WebP the viewer saves: a photo written at 0.95 loses more than it needs to, one written at 0.80 is re-saved larger than it needs to be. Dropping the quality key restores the matching, since options.quality is only consulted when set.
- Lenguaje dominante
- TypeScript
- Estrellas
- 2
- Forks
- 1
- Merge medio
- 18 h 59 min
- PR fusionados (30 d)
- 47
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nextcloud-libraries/nextcloud-viewer
-
type: bug
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
nextcloud-libraries/nextcloud-viewer#190 ·
Los mantenedores suelen responder en 1 día
-
type: tests
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
nextcloud-libraries/nextcloud-viewer#111 ·
Los mantenedores suelen responder en 1 día
-
type: enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
nextcloud-libraries/nextcloud-viewer#110 ·
Los mantenedores suelen responder en 1 día
-
type: enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
nextcloud-libraries/nextcloud-viewer#106 ·
Los mantenedores suelen responder en 1 día
-
type: enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
nextcloud-libraries/nextcloud-viewer#105 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de nextcloud-libraries/nextcloud-viewer
Issues similares
-
area:frontend kind:bug priority:p2 ready
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
handsontable/hyperformula#1879 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
RunestoneInteractive/rs#1661 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
capricorn86/happy-dom#2594 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día