Mobileread
Change the media type after renaming?
#1  The_book 02-14-2020, 09:21 PM
When I run epubcheck plugin, I find that some of my images are named with wrong suffix name. After change the suffix name by renaming function, epubcheck plugin tells me that now in opf file the media type do not match.
So I want to know if your can change the media type after renaming?
Reply 

#2  DiapDealer 02-14-2020, 09:34 PM
Sure. The manifest section of the opf file is where mimetypes are declared.
Reply 

#3  The_book 02-14-2020, 09:52 PM
Quote DiapDealer
Sure. The manifest section of the opf file is where mimetypes are declared.
I know, and I can change it by editing the opf file. It is just that I think can be done by Sigil automatically.
If the mimetypes are decided by the suffix name, it should by change when rename the suffix name. If the mimetypes are decided by what the file exactly is, it should be the actual mimetype when files are added.
Reply 

#4  KevinH 02-14-2020, 10:23 PM
The mediatypes are determined by the opf manifest when the epub is first loaded. How on earth did you end up with both the wrong file extension and the wrong mediatype?

Why can't you just use find and replace to fix the opf?
Reply 

#5  DiapDealer 02-14-2020, 10:25 PM
Quote The_book
I know, and I can change it by editing the opf file. It is just that I think can be done by Sigil automatically.
If the mimetypes are decided by the suffix name, it should by change when rename the suffix name. If the mimetypes are decided by what the file exactly is, it should be the actual mimetype when files are added.
Should's a funny word. I liked it better when you were asking rather than declaring how things "should" be.

Still, we'll take your "suggestion" under advisement.
Reply 

#6  The_book 02-14-2020, 10:38 PM
Quote KevinH
The mediatypes are determined by the opf manifest when the epub is first loaded. How on earth did you end up with both the wrong file extension and the wrong mediatype?

Why can't you just use find and replace to fix the opf?
What I mean starts with a image file with wrong suffix name. When I import it into Sigil, Sigil use the suffix name to decide the opf manifest.At this time I have file with wrong suffix name and mediatype decided by the wrong suffix name. After using epubcheck, I find the wrong suffix name, and rename it.Now I have file with right suffix name and mediatype still decided by the wrong suffix name. Again, I use epubcheck, which tell me I have wrong mediatype.
Reply 

#7  DNSB 02-14-2020, 11:59 PM
Perhaps a better request would be to have Sigil inspect the images during import to determine if the file type and image type match. I've seen the imghdr Python library used for testing and supplying information for renaming if needed (not sure but think Python3 required).

OTOH, when importing files with the wrong file type—"Garbage in, Garbage out" comes to mind—it might be better for the user to do some work before importing the image files. I might just be showing my paranoia but I tend to get nervous about files with incorrect file types. Am I the only one who remembers various forms of malware that hid themselves within images where one tactic was changing the image file type. It's a .png not a .jpeg so we won't check the EXIF data for instance.

@The_book: Since you know changing the file type when renaming the image file is going to trigger the mimetype error, why not change the mimetype at the same time?
Reply 

#8  The_book 02-15-2020, 02:54 AM
Quote DNSB
@The_book: Since you know changing the file type when renaming the image file is going to trigger the mimetype error, why not change the mimetype at the same time?
Because I don't like to edit the opf file directly.I want Sigil to form and change the opf file automatically.
Also, since the mimetypes are deceded by the suffix name when imported, I enjoy the idea that when I change the suffix name, Sigil can change the opf file just like what happened when I import files.
Reply 

#9  DNSB 02-15-2020, 03:47 PM
Quote The_book
Because I don't like to edit the opf file directly.I want Sigil to form and change the opf file automatically.
Also, since the mimetypes are deceded by the suffix name when imported, I enjoy the idea that when I change the suffix name, Sigil can change the opf file just like what happened when I import files.
Given that the filetype for the image file is incorrect, as I said before: GIGO.

Perhaps you, as part of your work flow, should be checking the image files before importing them if this is happening often enough that you feel requesting that Sigil correct such files is worthwhile.

I will admit to being rather curious as to where you are obtaining those misnamed image files. Other than user error such as renaming all the images in a directory, I don't need to use more than both hands to count the number of such misnamed image files I've seen in the last 4 decades.
Reply 

#10  BetterRed 02-15-2020, 05:50 PM
Quote DNSB
Given that the filetype for the image file is incorrect, as I said before: GIGO.

Perhaps you, as part of your work flow, should be checking the image files before importing them if this is happening often enough that you feel requesting that Sigil correct such files is worthwhile.

I will admit to being rather curious as to where you are obtaining those misnamed image files. Other than user error such as renaming all the images in a directory, I don't need to use more than both hands to count the number of such misnamed image files I've seen in the last 4 decades.
Really! You obviously don't filch stuff from pinterest, deviantart, etc

I bought a commercial graphic novel a few months ago, when I unpacked it I discovered all the so-called .webp files were in fact .png files. There are people out there who think changing the file extension will do the conversion.

BR
Reply 

  Next »  Last »  (1/2)
Today's Posts | Search this Thread | Login | Register