forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Adding text comments to JPG, PNG
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sun Sep 12, 2021 3:23 am    Post subject: Adding text comments to JPG, PNG Reply with quote

Is it possible to create addition to Clearwin to place text comments to saved JPG/PNG files? Would be very useful function
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sun Sep 12, 2021 9:10 am    Post subject: Reply with quote

Dan

How is the image created and exported? If you are using a "drawing surface" why not just call draw_characters@?
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sun Sep 12, 2021 10:19 am    Post subject: Reply with quote

This idea to store data inside image started long ago when i added all initial settings files to the output data it generated. Just to easily modify it and start new variants. Because initial files are small and resulting data large this did not eat up much space but was very convenient when years later you return to this case.

Things are that now we all store more and more graphics files on our disks too. I have probably a million of them already created over 3-4 decades. And i often when see the graphics file become lost to find how it was created, what are all needed settings and where are the exe codes which created it. I started keeping titles on top of files. Then all file names became longer and longer and longer. Then these names became automatically code generated telling about major parameters for the plots....

The idea now is to save the entire initial files which created data for the plot, all the paths and links on relevant files and finally the settings for the plot itself (as now %pl plots have their own settings files too). In this case when it will be needed you will easily find *all* needed data. This is much better than to store limited amount of data you can place using drawing_characters@ which i currently do. This became a problem to me lately because i am buried in the 100s of terabytes of data and dozen of places where it can be residing. Keeping info initial settings is like each cell of a human body keeps the whole DNA information for the entire body because by volume this part is really negligible and it has no sense to keep a part of info when you can keep it all.

Also i looked at my class photos recently and found that forgot the names of some of my classmates. I thought - would be great if hidden text inside jpeg files kept all the names (something like from left to right in the first, second and third row ...)


Last edited by DanRRight on Tue Sep 14, 2021 7:00 am; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sun Sep 12, 2021 3:45 pm    Post subject: Reply with quote

You can add data manually to a jpeg file by right clicking on the file in File Explorer. Select Properties and then Details. Click to the right of Title and enter the title in the box. The same for other fields. Click OK to save.
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Mon Sep 13, 2021 9:06 am    Post subject: Reply with quote

Yea, thanks, but the idea is you just click like we do right now and not only the graphics file will be created, but the comment added too.

By the way are you able to add the comment manually to PNG file? I can add it to JPG (limit 30KB) but can not do anything with PNG
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Sep 13, 2021 10:44 am    Post subject: Reply with quote

I don't know if you can do anything with png files.

How would it work for jpeg files? Are you calling export_image@. How would you supply the data?
Back to top
View user's profile Send private message AIM Address
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Mon Sep 13, 2021 12:25 pm    Post subject: Re: Reply with quote

DanRRight wrote:
By the way are you able to add the comment manually to PNG file? I can add it to JPG (limit 30KB) but can not do anything with PNG


Many image-manipulation programs can do that. For instance, Irfanview for Windows. Click-drag a small rectangle where you want to place text, then Edit->Insert Text. You can change the text attributes (size, font, color), and then save the modified image.

The procedure that I just described is manual. Some features of Irfanview can be accessed from command line options and batch file processing.
Back to top
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Tue Sep 14, 2021 4:48 am    Post subject: Reply with quote

Dan, I get what you are looking for; a way to insert specific information on when/how/why/ and with what an image was generated. I can see this as useful in order to document under what conditions an image was generated.

Adding actual text to an image (Edit->Insert text) would be one way, but then it is not searchable by the computer, while adding an actual text comment is. Similar to adding GPS coordinates to an image on your cellphone. It helps later, for sure!

For my JPG images, I would love to be able to insert a "tag" as text that would define the parameters of creation of the image. No way for BMP, I don't believe. Currently, I can do this inside a PDF by selecting a very small font size that will never be printed, yet can be searched for!

Bill
Back to top
View user's profile Send private message Visit poster's website
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Tue Sep 14, 2021 6:14 am    Post subject: Reply with quote

Paul,
As to how it would work - i do not know. May be export_image@ has to have additional option for saving text label. Or may be it could be independent subroutine which adds text after the image file was created...As to PNG i see there exist third party software claiming that it can place and read text in all graphics files including PNG...

Mecej4, thanks for the info.

Bill, from the first days of IBM PC i use Total Commander (initially it was Norton Commander, then Windows Commander. On Android currently there are many such tools for example Ghost Commander) which searches for the text inside everything including JPG files. By the way just found that new version of TC finally doing index searches i asked them to add for years which means instant search in the entire computer (such indexing tools were popular 20 years ago and then disappeared from my busy view, they searched your computer and the internet at the same time with the speed of Google, you have not yet finished typing and they already found you something relevant). Tool is called "Everything"
Back to top
View user's profile Send private message
Robert



Joined: 29 Nov 2006
Posts: 444
Location: Manchester

PostPosted: Tue Sep 14, 2021 8:39 am    Post subject: Reply with quote

Can you not draw the image onto a graphics surface, add the text and resave? You have control over fonts and colours that way.
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Sep 14, 2021 8:54 am    Post subject: Reply with quote

A binary editor displays the data somewhere in the middle of the file so there will be offsets somewhere in the header to say where to find this data. The data section appears to be of fixed length.

The following reference may lead to the required header information (https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format).

Given all the necessary information (and perhaps a free day) it would be possible to write a routine for JPEG files but how many users would use it and how much time would it save? Users would still need to write code that automates the process of filling in the fields.
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Tue Sep 14, 2021 1:32 pm    Post subject: Reply with quote

Robert,
Currently I place info about plot into

1) its filename
2) the plot title and of course X and Y captions
3) into so called legend on the plot (with draw_character@) - additional info exactly on the area of the plot. I hope with time legends will be added into %PL professionally.

But that is not what i was talking about. I thought that may be there exist quick way to add hidden text to JPG/PNG files. That text may contain entire data to completely reproduce the plot.
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Wed Sep 15, 2021 2:52 am    Post subject: Reply with quote

There are many modes of "attaching" text to an image (or other structured file, such as an EXE or a Zip). The posts above seem to focus on having the text added as graphics entities to the image stored in the PNG file.

It is also possible to append the text to the image file as text. The added text is part of the file, and can be detected and parsed using appropriate filters and utilities, but is never shown in the image itself. For example, consider

Code:
T:\>type libs.txt
LIBS= libdyna.lib libansys.lib shell32.lib user32.lib comctl32.lib comdlg32.lib Iphlpapi.lib

T:\>copy /b image.png+libs.txt image1.png
image.png
libs.txt
        1 file(s) copied.

T:\>grep -c LIBS image*.png
image.png:0
image1.png:1


The newly created file image1.png contains exactly the same image as the original file image.png, but contains the appended text that was in libs.txt.
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Wed Sep 15, 2021 7:13 am    Post subject: Reply with quote

Paul,
Thanks for the hints. How many people will use this? Initially as usually just few. But clearly our computer world becomes more and more visual and with right advertisement more people will use it. Placing text was initially niche functionality for digital photography to store shot and geolocation data. But looks like it is becoming widespread. People just do not know that they can edit this info. When major apps like WORD will allow accessing and editing hidden image data inside many will use it.

Mecej4,
Looks like this is most of what is needed, will explore this approach, thanks for the nice demo.

I imagine my Clearwin app with the Snapshot button as i use today when the JPG/PNG file will be saved (for example energy distribution function as a function of length is saved into this file with autogenerated name "_f_len20210911_191049 Time=0009 -256.5fs_001.png" giving the hint about it, date and time of creation, time in evolution of plasma, current number of data file, modification version number ) and additional line of text "Would you like to save the comment inside the image?" and radiobuttons "Save initial settings file?" "Save Clearwin Settings file?" and if you answer yes, the comment will be placed:

"Nickel flat target, PIC code exe date Oct 2019. Laser intensity ...... W/cm2, Normal incidence. All data files are in the W:\Nickel2019\a019......... " etc.etc.etc....

and two files will be placed inside the image. Say, months later all simulated data will be deleted because it is literally impossible to keep so many terabytes of it, but we can extract initial settings file from image file, run the code again and reproduce the data. We can also extract Fortran source which was used to create the plot and settings file (the one which %PL makes in its new Designer Mode). Now you will be journaling and documenting everything automatically like the human body cell somewhere in the butt keeps DNA responsible for everything including the brain Smile
Back to top
View user's profile Send private message
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Wed Sep 15, 2021 9:35 am    Post subject: Reply with quote

Both the JPEG and PNG standards provide for embedding blocks of text in an image file.

For PNG, see the paragraph"4.2.7. tEXt Textual data" in the documentation page at https://www.w3.org/TR/PNG-Chunks.html .
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group