This question is answered. Helpful answers available: 0. Correct answers available: 1.


Permlink Replies: 30 - Pages: 3 [ 1 2 3 | Next ] - Last Post: 2 Apr 25, 06:25 Last Post By: MarkusD Threads: [ Previous | Next ]
MarkusD

Posts: 789
Registered: 13-Apr-2006
Reduce size of .json files
Posted: 11 Oct 22, 19:08
 
  Click to reply to this thread Reply
Hi,

would it be possible that the jAlbum core limits the size (lets say to 1,000 characters) of a comment in the .json files? I do have folder comments which are aprox. 1 MB in size. So for my album I'm confronted with a "deep-data.json" ( 28,187,295 Bytes) and tree.json ( 10,996,282 Bytes), which makes using an album for example on a tablet, with low memory and low CPU, more or less impossbile.

Thanks, Markus
davidekholm

Posts: 3,844
Registered: 18-Oct-2002
Re: Reduce size of .json files
Posted: 11 Oct 22, 21:47   in response to: MarkusD in response to: MarkusD
Helpful
  Click to reply to this thread Reply
What skin are you using? This can be done by adjusting the skin's JSONMaker using the forEach method. The forEach method will visit each object. You can now adjust/limit comments for instance.
MarkusD

Posts: 789
Registered: 13-Apr-2006
Re: Reduce size of .json files
Posted: 11 Oct 22, 23:46   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Hi David, I'm using Tiger. The adjustment of comment is done how? With an external tool? I don't have the slightest idea where to look. Thanks
Laza

Posts: 1,464
Registered: 6-Sep-2005
Re: Reduce size of .json files
Posted: 12 Oct 22, 13:13   in response to: MarkusD in response to: MarkusD
 
  Click to reply to this thread Reply
Regarding the skin, you can limit the length of the captions (thumbnail and image) by changing the related template, e.g. removing the ${comment} variable. However, I think it's not really effective, as the JSON files already contain the comment, which is placed by jAlbum, so you can only avoid duplicating the comment this way.

By the way, I don't see the point of having 1MB comments, which are not used.

Shortening the comments might trigger HTML rendering problems if they contain HTML tags.
davidekholm

Posts: 3,844
Registered: 18-Oct-2002
Re: Reduce size of .json files
Posted: 12 Oct 22, 13:22   in response to: Laza in response to: Laza
Helpful
  Click to reply to this thread Reply
Attachment init.js (52.1 KB)
You could try adding the following to line 1819 of init.js, or right after the "if (jm) {" line:
jm.forEach(function(ao, json)  {
  json.putNotEmpty("comment", StringUtil.limit(json.get("comment"), 1000));
  json.putNotEmpty("description", StringUtil.limit(json.get("description"), 1000));	
});
And at line 28, add a declaration of the StringUtil type:
	StringUtil = Java.type("se.datadosen.util.StringUtil");


I've attached my modified init.js

I believe this will work.
MarkusD

Posts: 789
Registered: 13-Apr-2006
Re: Reduce size of .json files
Posted: 12 Oct 22, 18:33   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
I believe this will work.
This is true. ;-) David, Thanks a lot.

The tree.json was reduced from 7.41 MB down to 932 KB. And the deep-data.json was reduced from 7.64 MB down to 2.30 MB. The results are for a medium album.

So I have to change the init.js file after every update from Tiger, but that is fine.
MarkusD

Posts: 789
Registered: 13-Apr-2006
Re: Reduce size of .json files
Posted: 12 Oct 22, 18:38   in response to: Laza in response to: Laza
 
  Click to reply to this thread Reply
Laza wrote:
Regarding the skin, you can limit the length of the captions (thumbnail and image) by changing the related template, e.g. removing the ${comment} variable.
I already do this:
<%
	var safeTitle = stripHTML(title).replace(/"/g, '"').replace(/ & /g, ' &amp; '),				//" fixing syntax highlighting :)
//!!MD		safeDescription = stripHTML((pageType === 'page')? comment : description).replace(/"/g, '"').replace(/ & /g, ' &amp; '), 	//"
		safeDescription = safeTitle; //!!MD
		safeThumbPath = (typeof pageThumbPath === UNDEF)? shareImageFilename : pageThumbPath;


This reduces the size of the index.html files a lot.

By the way, I don't see the point of having 1MB comments, which are not used.
The folder comments we are talking about are not just plain text. Its more or less HTML code to show tables etc.

Shortening the comments might trigger HTML rendering problems if they contain HTML tags.
My original idea was to shorten the comments only for the json files, I think that will not break HTML tags.

Thanks
ming666

Posts: 90
Registered: 27-Aug-2019
Re: Reduce size of .json files
Posted: 28 Mar 25, 16:24   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
I tried this and it made no difference the the size of the json files produced.
Tried using your file and editing the one already in Tiger but no dice!
Am I doing something wrong?
JeffTucker

Posts: 8,081
Registered: 31-Jan-2006
Re: Reduce size of .json files
Posted: 28 Mar 25, 16:31   in response to: ming666 in response to: ming666
 
  Click to reply to this thread Reply
ming666 wrote:
I tried this and it made no difference the the size of the json files produced.
Tried using your file and editing the one already in Tiger but no dice!
Am I doing something wrong?

This routine will shorten very long comments, but if your album project doesn't contain any staggeringly long comments, it won't make any difference in the size of the file.
MarkusD

Posts: 789
Registered: 13-Apr-2006
Re: Reduce size of .json files
Posted: 28 Mar 25, 16:33   in response to: ming666 in response to: ming666
 
  Click to reply to this thread Reply
ming666 wrote:
I tried this and it made no difference the the size of the json files produced.
Tried using your file and editing the one already in Tiger but no dice!
Am I doing something wrong?
Please give me an hour or so, I'll give feedback.
MarkusD

Posts: 789
Registered: 13-Apr-2006
Re: Reduce size of .json files
Posted: 28 Mar 25, 16:55   in response to: ming666 in response to: ming666
 
  Click to reply to this thread Reply
ming666 wrote:
I tried this and it made no difference the the size of the json files produced.
Tried using your file and editing the one already in Tiger but no dice!
Am I doing something wrong?
Have you altered this file?
C:\Program Files\jAlbum\skins\Tiger\init.js

Keep in mind, if you updated Tiger after the installation of jAlbum, then you have to alter the code in another folder!

If you are on Windows then look for:
C:\Users[UserName]\AppData\Roaming\jAlbum\skins\Tiger\init.js
ming666

Posts: 90
Registered: 27-Aug-2019
Re: Reduce size of .json files
Posted: 30 Mar 25, 10:15   in response to: MarkusD in response to: MarkusD
 
  Click to reply to this thread Reply
MarkusD wrote:
ming666 wrote:
I tried this and it made no difference the the size of the json files produced.
Tried using your file and editing the one already in Tiger but no dice!
Am I doing something wrong?
Have you altered this file?
C:\Program Files\jAlbum\skins\Tiger\init.js

Keep in mind, if you updated Tiger after the installation of jAlbum, then you have to alter the code in another folder!

If you are on Windows then look for:
C:\Users[UserName]\AppData\Roaming\jAlbum\skins\Tiger\init.js


Thanks
Yes I changed that file and the one in app data. I haven't updated Tiger since and the json files remain the same size

ming666

Posts: 90
Registered: 27-Aug-2019
Re: Reduce size of .json files
Posted: 30 Mar 25, 10:17   in response to: JeffTucker in response to: JeffTucker
 
  Click to reply to this thread Reply
JeffTucker wrote:
ming666 wrote:
I tried this and it made no difference the the size of the json files produced.
Tried using your file and editing the one already in Tiger but no dice!
Am I doing something wrong?

This routine will shorten very long comments, but if your album project doesn't contain any >staggeringly long comments, it won't make any difference in the size of the file.
This routine will shorten very long comments, but if your album project doesn't contain any
staggeringly long comments, it won't make any difference in the size of the file.

What is your definition of a long comment?
Most of mine are indeed very long.

even if I am putting

StringUtil.limit(json.get("comment"), 10);


rather than
StringUtil.limit(json.get("comment"), 1000));


Edited by: ming666 on 30 Mar 2025, 10:18

Edited by: ming666 on 30 Mar 2025, 10:21
MarkusD

Posts: 789
Registered: 13-Apr-2006
Re: Reduce size of .json files
Posted: 30 Mar 25, 11:09   in response to: ming666 in response to: ming666
 
  Click to reply to this thread Reply
ming666 wrote:
JeffTucker wrote:
ming666 wrote:
I tried this and it made no difference the the size of the json files produced.
Tried using your file and editing the one already in Tiger but no dice!
Am I doing something wrong?

This routine will shorten very long comments, but if your album project doesn't contain any >staggeringly long comments, it won't make any difference in the size of the file.
This routine will shorten very long comments, but if your album project doesn't contain any
staggeringly long comments, it won't make any difference in the size of the file.

What is your definition of a long comment?

Mine are several 100KB in size. The biggest is 1 MB. But, I'm talking only of comments for folders not for pictures or videos.
ming666

Posts: 90
Registered: 27-Aug-2019
Re: Reduce size of .json files
Posted: 31 Mar 25, 10:47   in response to: MarkusD in response to: MarkusD
 
  Click to reply to this thread Reply

What is your definition of a long comment?
Mine are several 100KB in size. The biggest is 1 MB. But, I'm talking only of comments for >folders not for pictures or videos.

Ah, I am talking about comments on photos.
Does the above work around only work on comments for folders?
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums