After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 669818 - Calculation of file size totally erroneous
Calculation of file size totally erroneous
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: win32
unspecified
Other Windows
: Normal major
: ---
Assigned To: gtk-win32 maintainers
gtk-win32 maintainers
: 669825 673006 673597 673968 675539 675724 675967 675974 675978 675983 676098 676319 WrongFileSizeDisplay 676380 676459 677670 677756 677811 677957 678242 678260 678498 679096 679119 JPGexportsize 679653 680037 680474 681655 682497 682522 683368 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-02-10 16:53 UTC by grauerwolf55
Modified: 2018-05-24 13:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot: Save JPGs, file size precalculation (49.69 KB, image/jpeg)
2012-02-10 16:53 UTC, grauerwolf55
Details
test-case (1.25 KB, text/x-csrc)
2012-05-12 14:45 UTC, Massimo
Details

Description grauerwolf55 2012-02-10 16:53:37 UTC
Created attachment 207275 [details]
Screenshot: Save JPGs, file size precalculation

The precalculation of the size of JPG files shows totally erroneous values that don't make any sense.
The example in the attachement belongs zu a small picture of 53.7 kB uncompressed!
Comment 1 Michael Natterer 2012-02-10 18:04:51 UTC
Hah hilarious :) This is the last 2.6 release though, can you check this
with 2.7.4 please?
Comment 2 Michael Schumacher 2012-02-10 20:42:08 UTC
*** Bug 669825 has been marked as a duplicate of this bug. ***
Comment 3 Akhil Laddha 2012-03-24 11:58:16 UTC
grauerwolf55, can you reproduce problem with latest GIMP ?
Comment 4 grauerwolf55 2012-03-24 12:47:21 UTC
Akhil Laddha,

I didn't try it with 2.7.5. But I managed with GIMP 2.6.12 (because there are many important bugs fixed) using a simple trick:

1. Install GIMP 2.6.12-i686-septup.exe, but don't start it, because it's obviously broken!
2. In programs/gimp/lib/gimp/2.0/plugins you copy "file-jpeg.exe" to any folder (make a mental note, where :-) ), f.i. in "install" 
3. Install GIMP 2.6.12-i686-septup-2.exe, but don't start it yet!
4. Recover the old "file-jpeg.exe" to programme/gimp/lib/gimp/2.0/plugins overwriting the new one!
5. Start GIMP et voilà: The precalculation of the size of jpg-files works. 
Since then I've worked many day's with GIMP. I had no problems at all, everything work's stable.

There is still another bug when you open existing files. If you click on "force a new preview" you get a new thumb but no new file-size. There is only shown "5.0 EB", whatever that means. But I think, this is a little insignificant bug we can live with...

Sorry for my bad english, it's not my native language, but I hope I could help you!

Best regards
Wolf
Comment 5 Michael Schumacher 2012-03-28 16:09:00 UTC
The 2.7.5 installer for Microsoft Windows even mentions this as a known problem in the installer dialog.
Comment 6 Michael Schumacher 2012-03-28 16:09:32 UTC
*** Bug 673006 has been marked as a duplicate of this bug. ***
Comment 7 Michael Schumacher 2012-04-05 18:44:13 UTC
*** Bug 673597 has been marked as a duplicate of this bug. ***
Comment 8 Ivan 2012-04-10 10:40:00 UTC
Same problem here with 2.6.12
Comment 9 Michael Schumacher 2012-04-10 13:59:18 UTC
Same in 2.8.0-rc1, although the file sizes has become considerably smaller - only 1.3GB instead of 5EB ;)
Comment 10 Jason Mancini 2012-04-12 07:24:28 UTC
This bug was killing me on 2.6.12 always says 5.5 petabytes.  2.8-rc1 says 1.3GB always.  It renders GIMP absolutely useless for saving jpegs.  Thanks to the poster GrauerWolf55 above, I was able to install GIMP twice and swap the one file.  Not fixed for over 2 months!  For shame.
Comment 11 Michael Natterer 2012-04-12 10:10:32 UTC
Yes, it's a total shame that absolutely none of our many windows
users gives a shit about GIMP's problems on windows, steps up and
fixes some.

We have 0 (literally zero) windows developers, so either somebody
comes and fixes this stuff, or we will have to drop support for windows.

I am not joking.
Comment 12 Michael Schumacher 2012-04-12 17:43:26 UTC
*** Bug 673968 has been marked as a duplicate of this bug. ***
Comment 13 GrafxUser 2012-04-12 18:09:50 UTC
Don't resign, Mitch. We users are still able to work with files in GIMP and they are fine despite of the wrong displayed size.

Perhaps the following informations are helpful: 
- The problem is only on Windows. The versions 2.6.12 for Linux and Mac don't have this issue.
- The Windows' version 2.6.11 (Jernejs build) doesn't have this problem, too. 
A first glance at the code gave me the impression, that the function g_format_size vs. g_format_size_for_display may be the bugs root. There's one commit from 2011-09-30 18:30 on jpeg-save.c which looks 'interesting'. But I think the problem lies deeper in g_format_size, as this function is called from some more erroneous parts of GIMP, see bug #673006. I didn't find the functions definition in GIMPs code, but I found hints to GLib; also see the bugfix for bug #658467 and bug report #655336. So it seems, g_format_size is defined in GLib and the GLib version used in the Windows build is wrong. 
I currently have no time to come to grips with building GIMP and its dependencies on Windows, but maybe somebody else is able and willing to check this. Perhaps one of the Windows' version packagers (Jernej, Partha)?
Hope I could help.
Comment 14 Massimo 2012-04-14 17:23:57 UTC
I don't know how file-jpeg.exe is built on Windows, but if
file-jpeg.exe of 2.6.12 is wrong and it was built from the
branch gimp-2-6, then it does not use neither g_format_size
nor g_format_size_for_display see:

http://git.gnome.org/browse/gimp/tree/plug-ins/file-jpeg/jpeg-save.c?h=gimp-2-6#n199

vs

http://git.gnome.org/browse/gimp/tree/plug-ins/file-jpeg/jpeg-save.c?h=master#n206

The other thing that could be wrong is the usage of struct stat:

docs suggest to use GStatBuf to avoid problems with the various
combinations of mingw win32/64 and C libs

I'd try a s/struct stat/GStatBuf/
Comment 15 cbodendein 2012-05-05 19:32:20 UTC
I don't know exactly what they are talking about, but this user on gimpchat claims to have fixed it.  I tried to follow but it isn't clear.  Maybe someone here knows what they are talking about.

http://www.gimpchat.com/viewtopic.php?f=4&t=4057&start=10#p50077

This is still present in the recently published 2.8 final for Windows.
Comment 16 Lyle Kroll 2012-05-05 19:47:06 UTC
Yeah; I already posted at both GIMPChat and GIMPUsers that this bug still exists.   At least the tif bug is now patched.   gimprc conflict with PSPI and User filter paths still unfortunately exists too.    Oh well.   :)
Comment 17 cbodendein 2012-05-05 21:39:17 UTC
I think it is worth noting that on my Windows installations for 2.6.12 32-bit, the calculation is correct.  For me, only 2.8.0 showed this bug.
Comment 18 Michael Schumacher 2012-05-05 23:43:31 UTC
*** Bug 675539 has been marked as a duplicate of this bug. ***
Comment 19 Szpakowski 2012-05-08 10:54:59 UTC
Additionaly bug seems persist only in 64 bit windows systems. On my all 32 bit systems it works good.
Comment 20 Lyle Kroll 2012-05-08 11:05:06 UTC
Ah; bet you they did patch those bugs but didn't do so for GIMP 64-bit then Szpakowski.   :)
Comment 21 Szpakowski 2012-05-08 12:08:33 UTC
I look at the functions called for calculation and it looks like that:

http://developer.gnome.org/glib/stable/glib-File-Utilities.html#g-stat

and

http://developer.gnome.org/glib/2.29/glib-Miscellaneous-Utility-Functions.html#g-format-size

I don't have toolchain and time to check it, but remember that bug started something about 2.6.12, when compiled glib version changed. On function g_stat there is a mention about mess with 64 bit stat functions. So it might be a glib bug not only gimp.
Comment 22 GrafxUser 2012-05-08 15:55:33 UTC
Just fyi: I checked it again and removed all other software with its GLibs. But unfortunately on my Windows 7 (32 bit) system, GIMP 2.8.0 still shows 1.3 GB.
Comment 23 Michael Schumacher 2012-05-09 08:02:52 UTC
*** Bug 675724 has been marked as a duplicate of this bug. ***
Comment 24 Massimo 2012-05-12 11:25:38 UTC
The problem is in GLib. Cross compiling GLib with mingw64 
(64 and 32 bits) I get this warning:

gstdio.c: In function 'g_stat':
gstdio.c:491:3: warning: passing argument 2 of '_wstat64i32' from incompatible pointer type [enabled by default]
In file included from gstdio.c:27:0:
.../sys/stat.h:128:15: note: expected 'struct _stat64i32 *' but argument is of type 'struct GStatBuf *'

if I change struct stat with struct _stat64i32 in 
plug-ins/file-jpeg/jpeg-save.c I see the similar warning cross
compiling GIMP, but then the plug-in shows the correct size.

For the record the 1,3 G is the modification 
(or last access) time in seconds from Epoch.

There's already a bug report for a similar issue with msvc6,
dating back to 2010: Bug 619448.
Comment 25 Massimo 2012-05-12 14:45:29 UTC
Created attachment 213919 [details]
test-case

attaching a simple test program.

compiled with mingw64 its output on Win7 64bits is:

mingw64 version: 3.0 (_WIN64)
helloworld

stat is #define'd to '_stat64'
_wstat is #define'd to '_wstat64i32'


GStatBuf
size: 1336831682
atime: 1336832956
mtime: 1336831682
ctime: 2031646

struct stat
size: 1336831682
atime: 1336832956
mtime: 1336831682
ctime: 2031646

struct _stat64i32
size: 14
atime: 1336831682
mtime: 1336832956
ctime: 1336831682
Comment 26 Massimo 2012-05-12 14:50:16 UTC
moving to Product glib
Comment 27 Michael Schumacher 2012-05-13 08:38:48 UTC
*** Bug 675967 has been marked as a duplicate of this bug. ***
Comment 28 Partha 2012-05-13 14:09:27 UTC
re comment 24, in gimp-2.8.0 (release src), I changed strut stat to strut _stat64i32, but did not see any change when look at jpeg preview in the file-open dialog.
Comment 29 Michael Schumacher 2012-05-13 14:09:41 UTC
*** Bug 675974 has been marked as a duplicate of this bug. ***
Comment 30 Massimo 2012-05-13 14:38:40 UTC
(In reply to comment #28)
> re comment 24, in gimp-2.8.0 (release src), I changed strut stat to strut
> _stat64i32, but did not see any change when look at jpeg preview in the
> file-open dialog.

Yes changing jpeg plug-in only changes jpeg plug-in 
size computation.

There are, IIRC, 16 occurrences of g_stat in GIMP's sources, 
one of them will be responsible of file open dialog.
Comment 31 Partha 2012-05-13 16:39:25 UTC
You are correct. I modified the jpeg plug-in. The preview is controlled by gimpthumb-utils.c. Modifying this file fixes everything.

Thanks,
Partha
Comment 32 Michael Schumacher 2012-05-13 17:04:03 UTC
*** Bug 675978 has been marked as a duplicate of this bug. ***
Comment 33 Michael Schumacher 2012-05-13 20:51:51 UTC
*** Bug 675983 has been marked as a duplicate of this bug. ***
Comment 34 Alexia Death 2012-05-15 13:41:17 UTC
*** Bug 676098 has been marked as a duplicate of this bug. ***
Comment 35 Michael Schumacher 2012-05-18 14:19:05 UTC
*** Bug 676319 has been marked as a duplicate of this bug. ***
Comment 36 Michael Schumacher 2012-05-19 08:47:35 UTC
*** Bug 676354 has been marked as a duplicate of this bug. ***
Comment 37 Michael Schumacher 2012-05-19 18:14:59 UTC
*** Bug 676380 has been marked as a duplicate of this bug. ***
Comment 38 Michael Schumacher 2012-05-21 07:20:53 UTC
*** Bug 676459 has been marked as a duplicate of this bug. ***
Comment 39 André Klapper 2012-06-08 06:47:16 UTC
*** Bug 677670 has been marked as a duplicate of this bug. ***
Comment 40 Michael Schumacher 2012-06-09 15:52:37 UTC
*** Bug 677756 has been marked as a duplicate of this bug. ***
Comment 41 André Klapper 2012-06-10 14:23:30 UTC
*** Bug 677811 has been marked as a duplicate of this bug. ***
Comment 42 Michael Schumacher 2012-06-12 17:30:13 UTC
*** Bug 677957 has been marked as a duplicate of this bug. ***
Comment 43 André Klapper 2012-06-17 10:25:23 UTC
*** Bug 678242 has been marked as a duplicate of this bug. ***
Comment 44 Michael Schumacher 2012-06-17 19:04:07 UTC
*** Bug 678260 has been marked as a duplicate of this bug. ***
Comment 45 Michael Schumacher 2012-06-20 20:21:37 UTC
*** Bug 678498 has been marked as a duplicate of this bug. ***
Comment 46 André Klapper 2012-06-29 11:12:13 UTC
*** Bug 679096 has been marked as a duplicate of this bug. ***
Comment 47 André Klapper 2012-06-29 11:15:33 UTC
*** Bug 679119 has been marked as a duplicate of this bug. ***
Comment 48 Michael Natterer 2012-07-08 22:52:05 UTC
*** Bug 679597 has been marked as a duplicate of this bug. ***
Comment 49 Tobias Mueller 2012-07-09 22:25:40 UTC
*** Bug 679653 has been marked as a duplicate of this bug. ***
Comment 50 Michael Schumacher 2012-07-10 19:10:18 UTC
*** Bug 679597 has been marked as a duplicate of this bug. ***
Comment 51 Michael Schumacher 2012-07-16 18:06:59 UTC
*** Bug 680037 has been marked as a duplicate of this bug. ***
Comment 52 Michael Schumacher 2012-07-23 19:06:23 UTC
*** Bug 680474 has been marked as a duplicate of this bug. ***
Comment 53 yaomtc 2012-08-04 02:09:15 UTC
I was going to use GIMP for resizing photos to be 1 MB or smaller for web uploading, but ran into this bug, making my process much more difficult. I'll just have to use Phatch for that instead (it's better suited to batch resizing anyway). Hopefully this gets fixed soon.
Comment 54 Michael Schumacher 2012-08-11 14:51:59 UTC
*** Bug 681655 has been marked as a duplicate of this bug. ***
Comment 55 Chris Mohler 2012-08-22 20:56:37 UTC
*** Bug 682497 has been marked as a duplicate of this bug. ***
Comment 56 Chris Mohler 2012-08-23 14:52:02 UTC
*** Bug 682522 has been marked as a duplicate of this bug. ***
Comment 57 Chris Mohler 2012-09-04 22:14:54 UTC
*** Bug 683368 has been marked as a duplicate of this bug. ***
Comment 58 Lyle Kroll 2012-09-04 22:31:15 UTC
The saved preview size is always a little bigger then the actual size is now, but I can live with that.   :)
Comment 59 cbodendein 2012-09-04 22:35:23 UTC
(In reply to comment #58)
> The saved preview size is always a little bigger then the actual size is now,
> but I can live with that.   :)

Is it a little bigger, or is GIMP using base 10 for size calculation (1 MB = 1000000 bytes) and Windows is using base 2 (1 MB = 1048576 bytes)?
Comment 60 Lyle Kroll 2012-09-04 23:21:50 UTC
They fixed this issue in 2.8.2; you need to download and update GIMP cbodendein.   :)
Comment 61 cbodendein 2012-09-04 23:54:39 UTC
(In reply to comment #60)
> They fixed this issue in 2.8.2; you need to download and update GIMP
> cbodendein.   :)

I have 2.8.2. You were saying that preview size is a little bigger in 2.8.2 than the actual, but I am saying that I think the preview size is correct, but GIMP and Windows use different units to measure file size.
Comment 62 Lyle Kroll 2012-09-05 02:38:32 UTC
Oh; I see what you are saying now.   Many sites I visit require a file size of 200K or less.   At this size, it's usually around 3 or 4K smaller then what the GIMP preview size says it will be (a good thing; lol).   This small bug is no where near what was the issue for 2.8.0.   lol

:)
Comment 63 Max Mustermann 2013-10-12 17:03:44 UTC
I just tried to get the filesize in GIMP on exporting to JPEG and see 'unknown' because g_file_query_info returns nothing valuable.

Product: GLib 2.36.4 (in GIMP master, Mike Hennings nightly build from 7.10.2013)
Platform: Windows 8 (64 bit)

It works fine on XP (32 bit), Windows 7 (32 bit) and Windows Vista (64 bit), so I assume it's something in Windows 8.
Comment 64 Max Mustermann 2013-10-16 19:57:27 UTC
After the update to glib2 2.38.0 in GIMP master (Mike Hennings nightly build from 15.10.2013) nothing has changed: it works on Win7 (32 bit), but not on Win8 (64 bit). The JPEG export dialog in GIMP still shows filesize 'unknown' there.
Comment 65 GNOME Infrastructure Team 2018-05-24 13:46:02 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/509.