How can I get summary information from images? - delphi

How can I get the summary information for file images in Delphi?

You will have to use parsers for each file type. The simple solution would be to use something like GraphicEx and to load each supported image into a temporary object, extract the information you want then dispose of it.
For EXIF information (the information attached by modern day cameras) you might want to use a different component. I know there are a few components floating around that will give you access to this special format, however this data is not supported by all image types and is normally seen in JPEG files.

You don't need anything.
It's included in Windows (Win32 COM)
See on Win32 api group (classic question...)

Related

Use mkv to store custom data

I want to develop some simulation software. It produces long arrays of data. Is it good idea to store this data in mkv file with custom codec ? The goal of it is to get fast random access to data and avoid headache with handling big arrays(bigger then 32bit address space)
And if so, is there are any simple mkv c++ library ?
Also, mkv is a specific application of EBML, a sort of binary xml language, optimized for media. If you decided the features are right for you, EBML would be what you would use, which would allow you to customize for your specific application.
mkv is the file extension for the Matroska format, which would help you with your search.
Here is the Matroska source code page, which includes links to EBML and Matroska c libraries.
http://www.matroska.org/team/source-code.html
I'm pretty sure the things you get from mkv are nowhere near as sophisticated for scientific (simulation) data as HDF5. It was designed for exactly the use case you describe.

Programming screen recorder - output issues

I want record screen (by capturing 15 screenshots per second). This part I know how to do. But I don't know how to write this to some popular video format. Best option which I found is write frames to separated PNG files and use commandline Mencoder which can convert them to many output formats. But maybe someone have another idea?
Requirements:
Must be multi-platform solutions (I'm using Free Pascal / Lazarus). Windows, Linux, MacOS
Exists some librarys for that?
Could be complex commandline application which record screen for me too, but I must have possibility to edit frames before converting whole raw data to popular video format
All materials which could give me some idea are appreciated. API, librarys, anything even in other languages than FPC (I would try rewrite it or find some equivalent)
I considered also writting frames to video RAW format and then use Mencoder (he can handle it) or other solution, but can't find any API/doc for video RAW data
Regards
Argalatyr mentioned ffmpeg already.
There are two ways that you can get that to work:
By spawning an new process. All you have to do is prepare the right input (could be a series of jpeg images for example), and the right commandline parameters. After that you just call ffmpeg.exe and wait for it to finish.
ffmpeg makes use of some dll's that do the actual work. You can use those dll's directly from within your Delphi application. It's a bit more work, because it's more low-level, but in the end it'll give you a finer control over what happens, and what you show the user while you're processing.
Here are some solutions to check out:
FFVCL Commercial. Actually looks quite good, but I was too greedy to spend money on this.
Open Source Delphi headers for FFMpeg. I've tried it, but I never managed to get it to work.
I ended up pulling the DLL wrappers from an open source karaoke program (UltraStar Deluxe). I had to remove some dependencies, but in the end it worked like a charm. The relevant (pascal) code can be found here:
http://ultrastardx.svn.sourceforge.net/viewvc/ultrastardx/trunk/src/lib/ffmpeg-0.10/
There was some earlier discussion with a Delphi component here. It's a very simple component that sometimes generates some weird movies. Maybe a start.

Binary Serialized File - Delphi

I am trying to deserialize an old file format that was serialized in Delphi, it uses binary seralization. I know nothing about the structure of the file except some very high level records that are in it.
What steps would you take to solve this problem? Any tools etc?
A good hexeditor, and use the gray matter to identify structures.
If you get a hint what kind of file it is, you can search for more specialized tools.
Running the unix/Linux "file" command can be good too (*) See Barry's comment below for how it works. It can be a quick check for common filetypes like DBF,ZIP etc hidden by using a different extension.
(*) there are 3rd party builds for windows, but they might lag in versions. If you can do it on a recent *nix distro, it is advised to do so.
The serialization process simply loops over all published properties and streams their value to a text file. If you do not know the exact classes that were streamed to the file you will have a very hard time deserializing the file. (if not impossible)
A good hex editor is first. If the file is read without buffering (eg read directly from a TFileStream) you could gain some information when using ProcMon from SysInternals; You can see exactly what data is read in what chunks and thus determine more quickly where the boundaries are between the structures you already identified.

Convert Doc,Docx to TIFF with delphi

Hi
How can i convert doc,docx to TIFF whith delphi?
In short, you can't.
Doc and TIFF are two completely different things. It's not like converting from BMP to TIFF (two image formats), or WAV to MP3 (two audio formats). For very limited Word documents, I suppose you could run Word through OLE automation (or maybe even embed Word in your application for better control), then take a screenshot, but I think your problems runs deeper than that. Maybe you could provide some more info about what you try to achieve?
I've done it from within Word, however the code is long lost I'm sorry.
I created an Office plugin using the Add-in Express Component.
I used Word automation to convert the current document to RTF, used WP-Tools to render, which gave me the bitmap for each page. Finally I used GDI+ to create the multi-page TIFF.
The standard trick is like with word to pdf: find a virtual printer that outputs tiffs, and instrument word over OLE to print to the virtual printer.
If I put "tiff printer virtual" in google, I see quite some hits. (not all free though, and of course it complicates installation to use two programs (word+printer) to do this)
Word is not able to save its documents to TIFF format. Your best options are to use third party software which can do that. Just google for Doc to Tiff.
When looking for tools to do this, you should also be aware that not all TIFF files are faxable. TIFF files can contain a whole range of image formats and sizes. You need to find a tool which can convert your document to monochrome bitmaps 1728 pixels wide, with the page images each in a single strip and with a compression method supported by your fax software.
A good fax software usually comes with a fax printer driver, check with the maker of your fax software if they have one. With a driver you can simply use OLE Automation to make Word print the document to this driver. The fax software we use expects the fax number and other parameters embedded in the text like this: ##NUMBER12345678##

JPEG built-in checksum / fingerprint?

I'm putting together a script to find remove duplicates in a large library of images. At the moment I'm doing a two pass filter of first finding files of the same size and then doing a sha256 on a 10240 byte piece of the file to get a fingerprint of the files with the same size (code here).
It works well, but I'm guessing there are probably checksums built in to the jpeg format that I could use instead of doing the sha256.
Does anyone know if there are checksums or other components that could act as checksums / fingerprints? If so, is there an efficient way to access them?
I don't think the JPEG specification includes any kind of checksum in the way you're describing.
A JPEG can contain a thumbnail as part of its EXIF metadata, though. It's not a perfect indicator, since it's possible for two different images to have the same thumbnail. There's at least one documented case of a thumbnail not being replaced after the image had undergone substantial modifications, said thumbnail revealing much more than the publisher had intended.
Its been awhile since I've dug into the IJG library, but I don't think there's an easy class member or function call you can use there to check for some type of fingerprint. You could use the built in EXIF tags if you can control the encoding of the images...
I'm just built a very similar script. I don't want to checksum metadata I want to see if the actual images are duplicates even if tags have been modified. Best for that is not to sort by size, but do sort by the checksum istelf. I use jhead to remove metadata and then checksum the whole file (but I also thought about just doing part of it, but actually I don't think it saves much time). jhead doesn't use shared memory (pipes) and does overwrite so I just copy the file to shared memory first. I place the checksum in the ImageDescription field for later faster retrieval. Obviously this also allows to check image integrity later and is part of why I checksum the whole thing. Tip: exiv2 is MUCH faster for reading and writing the metadata than exiftool for one at a time decision based manipulation.
In JPEG standard(ITU-T.81) i believe there isn't any field/syntax element which has a checksum or such, for the whole compressed jpeg image file. Unless a customised application puts such filed in the Application segment, or as meta data for which segments are provided in the standard.
So to serve your purpose, what you are doing is one soln.
Other could be some kind a application wrapper which will call some binary file compare utlitiy (like beyond compare, or even a windows command fc /b) and check the result of that compare utility and take the decision u want to.
-AD
One way you could perform is reduce all images to a fixed size and store that as a thumbnail. Then the image comparison would compare similar sized images and give you a chance of being a duplicate - useful if you have cropped (unless cropped heavily) or resized images and want to find those 'duplicates'.
In the XMP specification there are document ID and version ID which should uniquely identify the version of the image.
The problem with these (and with any other metadata-based identification method) is that it might not be respected by some applications that can change the content of the jpeg updating the metadata accordingly.

Resources