Read document (.doc) with images - ruby-on-rails

I need to read document texts with ruby and then perform some operations on their contents. Some of these documents include images that I need to upload to my server and later show the data with images. Any idea on how I can achieve this?
I'm thinking of using doc_ripper/docsplit, but ripper doesn't talk about images extraction, and docsplit seems to only take a screenshot of the entire page.
If this is not possible, I am fine with a way to recover the image file name in the right position, so then I can extract the file and upload it manually.

Related

Role of Augmented Images

What is the role of Augmented Images Database?
I am using arcoreimg tool to generate the img database, but why do need to generate it. I know it is a very basic question please provide your guidance
I am new to AR following Google AR SDK, Please help.
The role of the AugmentedImageDatabase is to store a compressed representation of the images you'd like to track. This is used by ARCore to detect images in the real world.
Generating a database at compile time with the arcoreimg tool has several advantages:
Your app no longer needs to bundle the original PNG or JPEG files. Your app would instead include a smaller database file, resulting in a smaller APK size.
Your app no longer needs to decode the original PNG or JPEG files to extract the image's feature points at runtime. This is an operation which takes roughly ~30ms for each image.

What are some options for handling image uploading/compression in ASP?

please bear with me as I'm not trying to frustrate anyone with inane questions, and I did google search this but I couldn't really find anything recent or helpful.
I am a novice programmer and I am using a classic asp web application. I just enabled the users to upload and download images, but I'm quickly regretting it as it's eating up all of the router bandwidth. I am finding my solution inadequate, so I wanted to start over.
My desire is threefold with this functionality:
Compression. I understand that this is impossible to do BEFORE uploading without some kind of Java/Silverlight/Flash portion of the application to handle uploads, correct? What is the common way most places go about this? Just allow regular file uploads and compress once they are on the server?
Resizing. I want to resize all images before they are uploaded to a reasonable size, instead of just telling users that try and upload huge camera images that they can't upload. I figure I just want to let them upload and have it resize for them before uploading. Does this functionality exist already?
Changing filetype. I want to allow users to upload all image file types but make them .jpg on the server after the upload.
With these three requirements, how hard is it to implement something like this in just pure code and libraries? Would it be better to just use a 3rd party plugin, such as ASPjpeg or ASPupload? Have you encountered something similar, and what was your solution?
Thanks.
Take a look at ASPJpeg and ASPUpload from Persits. We use these components to upload a full size image (can be png even though the library is "ASPJpeg"), resize it to several different sizes we need on our site, then store the resized images on the server in a variety of folders. The ASPUpload component is a little tricky but if you follow their sample code you'll be fine.
I never found a good component for decompressing uploaded zip files and had to write my own, which I've since abandoned. In the end with upload speeds increasing and storage getting so cheap, it started to matter less and less that the files were compressed before being uploaded.
EDIT: Just noticed you mentioned these components in your question. Consider this an endorsement of your idea to use them. :-)

Save image and encrypt it so that no one can access

Currently I'm using this tutorial now but I need some help in saving it to an image. For security purposes, is it possible to encrypt the file. And also, only my app will access the said file. I'm asking for help for saving it as image but encrypted, as well as how can I access the encrypted file. Thanks!
It is possible to encrypt any file. The difficult part of your question is if you really want the resulting output to still be an image, rather than a random seeming array of bytes. Image files have strict formats while encrypted files appear to be random and unformatted.
It is not clear, but you may be wanting something like steganography, where one image is hidden inside another. The hidden file can either be your plain image, or the encrypted version of your image. If you hide the encrypted version, then obviously you will need to decrypt it before you can display it.

How to write or modify EXIF data for an existing image on the filesystem, without loading the image?

I've asked similar questions before, but have not received a definitive answer. Seems that there must be a way to simply add/modify metadata to an image without loading the image into memory, without having to deal with directly reading bits.
Seems like ways exist when using CMSampleBufferRefs, but I need to be able to do this with a regular image already saved to disk.
For instance, given a very large png at /Documents/photo.png, I want to modify its exif metadata without having to load that image.
You can use libexif - I've had success with compiling it for iOS before. With libexif, you can modify any image's EXIF metadata.
If you know how to modify the EXIF, you can modify the binary data directly from the file. Just replace in the image the binary portion with the new one.
I don't know if objective-c permit this, but in ansi c should be simple. The complicate part is to identify the exact part to change.

Obfuscating images

I want to distribute a few images and not allow others to see them unless they are using my program. My intention will be to use JPG files in which I will alter the header so other image viewers cannot read them anymore. For example I can delete the bytes 7-10 which are the magic signature for JPG. Later, my program will reconstruct the header and show the JPG file.
Question: how do I do this on the fly, without reading the “broken” JPG file, restoring the header, saving the good file to disk and then re-loading it as a “good” JPG file?
Load the "broken" file into a TMemoryStream, patch the bytes in-memory, and use TGraphic.LoadFromStream() to load the fixed JPG file.
Encrypt them. Load the encrypted image, decrypt in memory and then do the loadfromstream like mghie suggested.
Why not just encrypt the images with a private key and distribute your public key to the people you want to view the images? much easier to distribute a public key than writing some custom software and distributing that. Don't forget; anything displayed on screen can be screen captured. The fact a custom-mangled JPEG can only be displayed with your app is no protection. Also don't forget; people can simply distribute your software with the mangled image.
Mghie's answer is about as good as you'll find, but it's not likely to be too effective. If someone wants to look at your images and they know anything about image formats, they'll open it in a hex editor and most likely recognize what they see as a JPEG with the magic header removed.
If you really want to keep someone from viewing your images, construct your own image format, (it's not as hard as it sounds, really,) and put as little metadata in as possible, and then hope that works. Or encrypt them, or put them into an archive, (construct your own archive format for best results,) and hope that works.
Thing is, ultimately, anything that's encoded has to be decoded before it can be shown, and any sufficiently-talented hacker can trace their way through your decoding routine and figure out how it works. Why are you trying to hide things from your users anyway?
You could make it more difficult for them by byte packing the images as encrypted resources. But like anything else if they have access to the files that could get the images out. It just depends on how much effort the are willing to use.
Depending on how secure you need it to be you could do something as simple as obfuscate the file extension to an extension that is only opened with your application. This will only work if its not super secret images that you are changing.

Resources