Posts:
783
Registered:
13-Apr-2006
|
|
|
|
Reduce size of .json files
Posted:
11 Oct 22, 19:08
|
|
|
|
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
|
|
|
Posts:
783
Registered:
13-Apr-2006
|
|
|
|
Re: Reduce size of .json files
Posted:
11 Oct 22, 23:46
in response to: davidekholm
|
|
|
|
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
|
|
|
Posts:
1,458
Registered:
6-Sep-2005
|
|
|
|
Re: Reduce size of .json files
Posted:
12 Oct 22, 13:13
in response to: MarkusD
|
|
|
|
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.
|
|
|
Posts:
3,826
Registered:
18-Oct-2002
|
|
|
|
Re: Reduce size of .json files
Posted:
12 Oct 22, 13:22
in response to: Laza
|
 |
Helpful |
|
|
|
|
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.
|
|
|
Posts:
783
Registered:
13-Apr-2006
|
|
|
|
Re: Reduce size of .json files
Posted:
12 Oct 22, 18:33
in response to: davidekholm
|
|
|
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.
|
|
|
Posts:
783
Registered:
13-Apr-2006
|
|
|
|
Re: Reduce size of .json files
Posted:
12 Oct 22, 18:38
in response to: Laza
|
|
|
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, ' & '), //" fixing syntax highlighting :)
//!!MD safeDescription = stripHTML((pageType === 'page')? comment : description).replace(/"/g, '"').replace(/ & /g, ' & '), //"
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
|
|
|
Posts:
90
Registered:
27-Aug-2019
|
|
|
|
Re: Reduce size of .json files
Posted:
28 Mar 25, 16:24
in response to: davidekholm
|
|
|
|
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?
|
|
|
Posts:
8,058
Registered:
31-Jan-2006
|
|
|
|
Re: Reduce size of .json files
Posted:
28 Mar 25, 16:31
in response to: ming666
|
|
|
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.
|
|
|
Posts:
783
Registered:
13-Apr-2006
|
|
|
|
Re: Reduce size of .json files
Posted:
28 Mar 25, 16:33
in response to: ming666
|
|
|
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.
|
|
|
Posts:
783
Registered:
13-Apr-2006
|
|
|
|
Re: Reduce size of .json files
Posted:
28 Mar 25, 16:55
in response to: ming666
|
|
|
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
|
|
|
Posts:
90
Registered:
27-Aug-2019
|
|
|
|
Re: Reduce size of .json files
Posted:
30 Mar 25, 10:15
in response to: MarkusD
|
|
|
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
|
|
|
Posts:
90
Registered:
27-Aug-2019
|
|
|
|
Re: Reduce size of .json files
Posted:
30 Mar 25, 10:17
in response to: JeffTucker
|
|
|
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
|
|
|
Posts:
783
Registered:
13-Apr-2006
|
|
|
|
Re: Reduce size of .json files
Posted:
30 Mar 25, 11:09
in response to: ming666
|
|
|
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.
|
|
|
Posts:
90
Registered:
27-Aug-2019
|
|
|
|
Re: Reduce size of .json files
Posted:
31 Mar 25, 10:47
in response to: MarkusD
|
|
|
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
|
|