Does anyone out there have a process or solution for displaying a corrupted image using wxpython. To be clear the image is corrupted but ACDSEE is still able to display it (all be it displayed corrupted), also the default windows fax/image viewer can display the image (all be it corrupted). When I try to process the image with wx I get an error and my script stops:
image.thumbnail((NewWidth, temp_height), Image.ANTIALIAS)
File "C:\Python27\lib\site-packages\PIL\Image.py", line 1559, in thumbnail
self.load()
File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 215, in load
raise_ioerror(e)
File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 52, in raise_ioerror
raise IOError(message + " when reading image file")
IOError: broken data stream when reading image file
I realize that I could just find where the error occurs and "skip" any corrupted images but I would rather be able to display them (than skip them) despite the corruption, as the two programs I mention above can. Any help/suggestions/guidance would be appreciated.
FYI. Not downing wx, I LOVE it! Ms Paint cannot display the image, it gracefully fails and gives a message that the image is corrupted (the equivalent of skipping) and MS Picture Manager actually hung on the image. So if the consensus is that wx just can't handle corrupted images I am willing to accept that and will add "skipping" code for corrupted images, but I wanted to ask the question before I did so.
I don't think wxPython supports this currently. I would just create some kind of default broken image or message that you can display instead. You might also try using the Python Imaging Library itself to open the image.
If you can find an open source image viewer that does work with corrupt images, than you should take a look at their code to see if we could patch wxPython.
Related
I am creating a report meant to be read/edited by MS Word. To do that I have created it from scratch and saved as .docx.
In this report I am including some images together with captions. All of the captions were added manually. Everything went fine, I have saved the document and closed Writer.
Now I want to put my hands on it again and, upon opening the report, this is what I am seeing:. Previously the figure was showing fine inside the text box (that inserting a caption creates). The text box is in the same position and size, but there appears to be a boundary over which it just displays white. I can reduce the figure's size inside the boundary of visibility, and a glimpse of the captions appears too .
Note that the red arrow disappears too.
Needless to say, I can not work on a 100+ pages document and then check again each picture, delete it and re-create it, check again the cross references and so on. I would much rather work with LaTeX, but I am required to deliver a .docx file.
I am working on Ubuntu 20.04, Libreoffice is updated to version 6.4.6.2 and the only plugins I have equipped it are TexMath and Zotero.
Thank you for your time.
I noticed the same thing. It seems to be an issue already in Libreoffice Writer between Linux and Windows. If you create a document on Linux with a cropped image and then open the file in Libreoffice on Windows the cropping of that image is already messed up. Happens to me with Libreoffice Version 6.3.5.2.
I am using prawn to generate pdf files which have lots of images so they come out quite large. I can open the file in Adobe Acrobat and then save it using the "reduce file size" option, and a 164MB file shrunk to 7MB and retained all of the image quality. I would like to replicate this compression in Ruby. I have tried using the compression settings which prawn offers and they have not had any effect on the file size. I suspect there must be a way to do it with RMagick, but I haven't figured it out yet.
I apologize for not including any code samples showing what I have tried, but I removed the prawn compression settings when they didn't have any effect, so I don't have anything to show.
Have you tried simply making a copy of the PDF with RMagick? That is, read in the PDF and write it back out again.
Also, check with the ImageMagick folks at https://www.imagemagick.org/discourse-server/. Any advice they offer you can be implemented via RMagick.
I'm attempting to parse an image that is possibly corrupt and it's driving me nuts trying to figure out what's wrong. Here is what I've deduced..
Example image: https://s3.amazonaws.com/edison_new/ffb3ccc402d6bd6-original
The images only show up in Chrome
Can't drag them to the desktop (on a mac).
Attempting to save them to computer yields a file that is "damaged or could not be open" when opening with Preview
Attempting to open in Photoshop yields "Could not complete your request because an unknown or invalid JPEG marker type is found."
Files are stored on Amazon S3
The meta data indicates the content-type to be image/jpeg
File definitely exists as you can see it in Chrome...
Anyone can help me deduce what is going on here??
The image is in WEBP format, its not natively supported in IE or FF so will not be displayed.
http://caniuse.com/#feat=webp
(I opened it in IrfanView to see what format it was)
Please take a look on the website http://quotes.rapidprototype.com.au/upload/ and upload STL File and press "Start Upload" button. You shall see the image of the object within the stl file as (.png) image. I want the same functionality(The image of the of the object within the stl file, rest of the work i can do). I want to get the image in .png or .jpr or .gif format as a 2D image. I want that the user can see the image of the object within the stl file that he/she uploads. I am using PHP.
Please assist me how can I achieve this using PHP. I shall be very thank full to you.
You could use ParaView www.paraview.org in the backend. This is free and reads stl as well as having the ability to save images. There is a python interface, so you can program it to do various things (starting by tracing your actions in the GUI). You can also give it options from the command line. ParaView has a web component, but it would probably be easier just to have PHP do a system call and look for the resulting image.
Test that it works on the command line before wrapping it in PHP
Has anyone come up with a way to make thumbnail type previews for matlab figures in windows?
I'm getting tired of saving a .png along with the .fig file just so I know what was in it.
A useful helper for this would be a command line utility for windows that can be provided with an image file and told to use that as the basis for the preview for a given file.
I could write a helper function in matlab that saved the .fig, made a temporary image file, then pushed that into the thumbnail using the command line utility.
You can write a function in C++ that tells Windows how to generate thumbnails from your file.
This link explains about it. Check out the section about Thumbnail Image handler. This is the function that you will need to implement.
From what I managed to understand, the procedure is this:
Write a in-process COM server (DLL) that implements IThumbnailProvider interface
Put the DLL file somewhere on your computer.
Write an entry to the registry, by using the procedure described in this page.
That still leaves you with the problem of thumbnail extraction from .fig file. As far as I know, fig files are nothing but mat files. I am fairly sure that it is possible.
You will need a custom save function for all figures. It will print a thumbnail of the image (by using the print command), and save it inside the figure.
I know that it isn't much information, but it can help you to get started. You might as well ask someone who is highly proficient in COM technology for more help. Thus, I recommend adding a COM tag to the question.
Edit(1) - I've found a good tutorial on the subject: