pworm Posted December 18, 2020 Share Posted December 18, 2020 Hi, is there a possibility to open image-files in TIFF format, which have "invalid"-fileextensions? All my files are double sided scans with fileextension file.1 (first side) and file.2 (second page). It is impossible to copy and/or rename these files. How can I make Paint.Net to accept *.1 and *.2 files as valid image-files? Thanks in advance & best wishes, Heiko Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted December 18, 2020 Share Posted December 18, 2020 The easiest way is to rename them & give them the correct file extension. Why do you state this is "impossible"? Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
pworm Posted December 18, 2020 Author Share Posted December 18, 2020 (edited) In my case it is 'impossible'. These files are opened from a read-only device and it is strictly forbidden to copy/save any of this data on the local storage. This is why I stated 'impossible'. What I didn't know & I don't understand is, why Paint.Net refuses to open the files just because of an invalid file-extension. Even the Windows Imageviewer doesn't care about the file-extension and opens any file. Never the less it would be great if anyone could point out a solution besides renaming the file. Is it somehow possible to tell Paint.Net that .1 / .2 is a know image type? Edited December 18, 2020 by pworm typo Quote Link to comment Share on other sites More sharing options...
Rick Brewster Posted December 18, 2020 Share Posted December 18, 2020 Paint.NET looks at the extension to determine the file type. It does not inspect the file itself in order to determine the file type. Windows Image Viewer is based on WIC (Windows Imaging Component) which does inspect the file itself in order to determine which codec to use for decoding the image. In order to open with Paint.NET, you will need to rename the file, or write your own FileType plugin that does what you need. There is no other solution. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
pworm Posted December 21, 2020 Author Share Posted December 21, 2020 (edited) Ok, thanks for your replys. Actually I am not a coder except some very basic Java knowledge. But I managed it to create a functional Filetype plugin. I have no idea, if it is good coding style but at least it is working for me and I'd like to share this here - just in case someone is having a similar problem. My code is based on a project template created by toe_head2001 - thanks man, that helped a lot: using PaintDotNet; using System.IO; using System.Drawing; namespace RoHoFileTypePlugin2 { public sealed class RoHoFileTypePlugin2Factory : IFileTypeFactory { public FileType[] GetFileTypeInstances() { return new[] { new RoHoFileTypePlugin2Plugin() }; } } [PluginSupportInfo(typeof(PluginSupportInfo))] internal class RoHoFileTypePlugin2Plugin : FileType { // Constructs a ExamplePropertyBasedFileType instance internal RoHoFileTypePlugin2Plugin() : base( "MyFileType", new FileTypeOptions { LoadExtensions = new string[] { ".1", ".2" }, }) { } /// <summary> /// Creates a document from a stream /// </summary> protected override Document OnLoad(Stream input) { Image image = Image.FromStream(input, true); return Document.FromImage(image); } } } Edited December 21, 2020 by pworm 1 1 Quote Link to comment Share on other sites More sharing options...
Ego Eram Reputo Posted December 21, 2020 Share Posted December 21, 2020 Great solution. Who cares if it is bad code?? It works for you and that is the important bit 2 1 Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker Link to comment Share on other sites More sharing options...
Rick Brewster Posted December 26, 2020 Share Posted December 26, 2020 On 12/21/2020 at 1:19 PM, Ego Eram Reputo said: Who cares if it is bad code?? It works for you and that is the important bit This is really important. A lot of people get hung up on their code being {insert negative words here}. Don't forget to answer: does it work for its intended audience? Does it need improvement (yet)? There is a LOT of code out there in the wild that is kinda janky looking but it works and solves real problems for real people in the real world. Case closed I don't care if my microwave has weird looking code because it works and doesn't give me any trouble, and I appreciate that. 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.