<wpg2> tags use always full-size versions

TheGoOse
TheGoOse's picture

Joined: 2002-12-31
Posts: 50
Posted: Sun, 2008-01-13 17:44

Hi.
I'm using WPG2 in my wordpress powered blog. I'm using <wpg2> tags for image display, using the image IDs, but the output always uses the full size version.

As you can se in my main page (http://www.ganso.org), I've set a WPG2 Tag Default Image Size of 656px, but the linked image is the 1024px one, even when I've got a 656px version of every image.

Any help? Thx.. :)

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Sun, 2008-01-13 21:30

TheGoOse,

Just a note of caution here, although you may have specified the resized image to be say for example 640, G2 will only resize by a ratio thus the true size may instead be 610 or 580 thus although you think you might have 656px size photos, in reality you might have less than that..

I done a LOT of testing with the linking of resized images and are pretty confident that they link fine.. Start with a smaller size and see what photos get linked to. I use a Firefox plugin called firebug which shows me the size of images etc thus I can see at a glance if I got the size of the photo wrong or not..

____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo

 
TheGoOse
TheGoOse's picture

Joined: 2002-12-31
Posts: 50
Posted: Sun, 2008-01-13 22:09

Thanks for the answer, ozgreg. I'm not sure I understand, though.

In the first page I have both horizontal photos (http://www.ganso.org/gallery/v/otros/PICT3610.jpg.html, with a 656x456 version) and vertical ones (http://www.ganso.org/gallery/v/fotoblog/januarymadness/PICT4281.jpg.html, which is 429x656), but the chosen version is the bigger one (1024x681 and 669x1024) for both of them.

I'm looking at the properties of the photos in the web page (Firefox 3 beta gives both the real and original size), and I'm quite sure the code is using the big version. I must be doing something wrong :)

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Sun, 2008-01-13 22:50

Can you please post the WPG2 Tag so I can see what is the Size parameter you are using..

____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo

 
TheGoOse
TheGoOse's picture

Joined: 2002-12-31
Posts: 50
Posted: Sun, 2008-01-13 23:09

I just use "<wpg2>ID</wpg2>", using the image ID.
I've defined size in the admin panel: WPG2 -> WPG2 Tags -> WPG2 Tag Default Image Size.

Is there another place to do it? I knew I was doing something wrong ;)

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Mon, 2008-01-14 00:27

To answer your Q, you can specify the size of the image in the G2 Selector Tool, the one you use to insert images with in your blog posts, it will post an tag like <wpg2>ID|SIZE</wpg2>

____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo

 
TheGoOse
TheGoOse's picture

Joined: 2002-12-31
Posts: 50
Posted: Mon, 2008-01-14 05:41

I've tried (<wpg2>ID|656</wpg2>), and I've got the same result.

I'm thinking I created the 656px version of the image AFTER I posted them in my blog. Is there some cache I should remove? I've already disabled the wp-cache plugin.

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Mon, 2008-01-14 09:30

OK lets try something like <wpg2>ID|400</wpg2> and see what size G2 points to..

____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo

 
TheGoOse
TheGoOse's picture

Joined: 2002-12-31
Posts: 50
Posted: Mon, 2008-01-14 10:09

I've been doing some trial and error tests with 2 images:

.

IMAGE 1 (horizontal)
--------------------

Gallery versions: 1024x681 (full size), 656x436
With <wpg2>ID|546</wpg> -> it points to the 656px × 436px version, scaled down to 546px × 363px
With >546 size, it points to the full size version

IMAGE 2 (vertical)
------------------

Gallery versions: 669x1024 (full size), 429x656
With <wpg2>ID|542</wpg> -> it points to the 429px x 656px version, scaled down to 354px × 542px
With >542 size, it points to the full size version

.

Maybe I should do it backwards, so I can find which rescaled versions should I make in Gallery so I can use <wpg2> size 656, which is the one I designed my theme with.

Thanks again, and please tell me if you need more data.

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Mon, 2008-01-14 21:43

TheGoOse,

Sounds to me like everything is working then as this is expected behaviour as the WPG2 will try to find the closest (LARGER) image to meet your specified size requirement and resize this downwards (resizing upwards is not an option because of poor image quality). When taking your examples, the closest larger image is 1024px thus when you specified a size 656px you got the 1024px image.

Is this clear?

____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo

 
TheGoOse
TheGoOse's picture

Joined: 2002-12-31
Posts: 50
Posted: Mon, 2008-01-14 21:56

You're right, but, let's take IMAGE 1: If I specify a size of 547 in the <wpg2> tag, which is less than 656, why does it use the 1024x681 version and not the 656x436 one? It's big enough to be rescaled downards to 547px wide.

.

My question is, which is the minimum size I should specify in galley2 configuration to use 656px in <wpg2> tags?

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Mon, 2008-01-14 22:21

I wonder if G2 checks the size of BOTH axis's to ensure they meet the specified size, can you test this for me. Also please verify that the G2 image size is the size you are expecting, you might specify 656 but it be a ratio size and may not be 656px, G2 will tell you the image size.

____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo

 
TheGoOse
TheGoOse's picture

Joined: 2002-12-31
Posts: 50
Posted: Mon, 2008-01-14 23:08

Well... it's quite complex, as far as I've seen.

First of all, I've checked image sizes in Galley, and they are really rescaled to 656px in their biggest side.

Using the same example image, is I set a <wpg2> size of 546, it uses the 656x436 version (http://www.ganso.org/gallery/d/4862-2/PICT4075.jpg). Vertical size is smaller than the one that I set, so it's not checking both axes.

With <wpg2> sizes of 547 or bigger, it uses the 1024x681 version (http://www.ganso.org/gallery/d/4036-4/PICT4075.jpg). I can't find any exact relationship between that numbers, though.

Maybe if you gave me some directions to the part of the code that checks sizes, I could trace it from there. I've never updated Gallery2 code, so I don't really know where to start.

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Tue, 2008-01-15 01:17

The size selection code is in the Gallery2 Imageblock, I know of at least one issue with the G2 Imageblock in G2.2 and have no doubt that others could exist and maybe fixed in G2.2 due out in the next month or so.. The code is in the \modules\imageblock\classes\ImageBlockHelper.class

Just a Note here the next release, we are moving away from the Imageblock function to our own as it is much simpler for us to maintain our codebase than it is to make changes in the G2 codebase.

____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo

 
TheGoOse
TheGoOse's picture

Joined: 2002-12-31
Posts: 50
Posted: Tue, 2008-01-15 06:57

Thank you. I'll try to find the problem in the Imageblock function while I wait to the new version :)

I'll probably install a CVS version of Gallery in another directory, too.

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Tue, 2008-01-15 21:54

Just a note of warning, the new version will be months away, this is pretty much a part time hobby for me so I do not get a lot of time to churn out changes..

If you are going to install the CVS, you will need to make a change to get the imageframes working, you will see a thread about this on this forum, hopefully the new version may help you out..
____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo

 
stephenju
stephenju's picture

Joined: 2005-07-05
Posts: 172
Posted: Sat, 2008-01-26 16:51

I ran into the same issue just recently. I set the WPG2 tag image size to 300. My photos have resizes of 300 and 640. The WPG2 tag images always end up with the 640 ones.

I did some test and find the size setting (300) is used to test both width and height of the available resizes. Since landscape photo at 300 wide is only 225 pixels tall, G2 (or WPG2?) skips it and uses the next larger size (640x400).

But the interesting thing is, if the WPG2 size is the same as the thumbnail size, it will then use the thumbnail image no matter what. Very inconsistant to me.

My solution is just to add a 400 resize to all albums and be done with it. It still doesn't get the 300 pixel wide pic. But at least it's not getting the full size 640 one.

Oh BTW. Greg. Long time no see. :)
-
東方之朱
I don't provide private help on Gallery or any software. Please post your issues in the forums.

 
bearmeister

Joined: 2008-04-30
Posts: 14
Posted: Wed, 2008-04-30 01:54

hi there,

i am also running into this problem and for me the main issue for me is more so that when the larger images get resized down by the browser they have a tendancy to look pixelated and lose their original feel, which is of particular problem with portraits that end up having excessively sharp edging. when you are talking about wedding portraits and stuff, even resized down a small amount doesnt come out looking very good imho. so what i am trying to do is to match the available image sizes in the gallery to that which would be presented using the wpg2 tag, so im effectively letting a proper image processor do the downsizing before hand and spoon feed the browser the exact image size it is going to use..

in my case my wpg2 images end up in the blog as either landscape 450x300 or portrait 300x450, and the available sizes in the gallery are 450 680 and original 1000. so i was hoping that it would go for the 450 images and then i would get 1:1 representation without browser resizing. what i am finding though is it is still going for the larger pictures, so for example even though the photo is to be represented in the blog as 450x300 and a 450x300 image size exists it ends up going for the 680x453 size.

if i am to understand the above correctly it is because wpg2 when looking for a best fit image compares the size of both axis as if they were the same, so when comparing a image to be represented as 450x300 the minimum length of any target image axis must be 450, when in reality the minimum horizontal needs to be 450 but the minimum vertical only 300. so hence a 450x300 image is really being compared as a 450x450 image, it thinks it can't use the 450x300 and makes a flawed decision to go for the 680x453 size unecessarily.

how would one go about correcting this? is this something that is likely to be fixed in the future? anyone have any useful ideas/suggestions would be appreciated.

 
capt_kirk

Joined: 2006-01-24
Posts: 492
Posted: Wed, 2008-04-30 03:03

I have code in the 3.1 development trunk of G2Image that gets the correct sized image by looking at both axes. When we port it to the new "imageblock replacement" in WPG2, it should take care of it correctly. (But like Greg said, it may be a few months before the code gets ported because both of us are busy with real life right now, trying to squeeze in some time to work on this.)

Oh, and "Hi," Stephen Ju! How's it going?

Kirk
____________________________________
G2Image Documentation, G2Image Demo Page, My Family Website

 
troutbum

Joined: 2008-06-14
Posts: 5
Posted: Sat, 2008-06-14 07:18

Hi

Am new user of wpg2 and came across this thread trying to solve a small issue. I am having the problem of wpg2 choosing the full sized max res image when I use the insert from "Insert a WPG2 tag for the current album:" from the Gallery 2 image chooser from the WPG2 button whilst editing/creating a post.

Everthing works as described per other peoples discussion if instead of inserting an album I insert an image from "Press button to insert checked image(s)".

I.e. if I havn't been clear - is the a bug when inserting an album rather than an image where wpg2 selects the full sized version of an image rather than the next fitting size above if you have told it a size rather than to use the thumbnail. To re-emphasise - my photos exists in sizes 300, 400, thumbnail(150), and a way bigger version so people can download the full camera version if they wish to print. When using <wpg2>imageID|200</wpg2> the insert works and displays the 300px version but when using <wpg2>albumID|200</wpg2> it fails and uses the full resolution image.

Is there something else I should be doing when inserting an album or is this a bug? If so where can I fix it?

 
ozgreg
ozgreg's picture

Joined: 2003-10-18
Posts: 1378
Posted: Sun, 2008-06-22 06:13

Hiya troutbum,

As has already been posted this is not a WPG2 bug, the issue will be

A) you have not rebuilt the resized Gallery2 images
B) the aspect ratio of your photos is smaller than the size you are specifying
C) The order of resizes in your album settings are not set from lowest to highest

I know this feature works because I tested it pretty much to death because of posts like this..

____________________________________
Wordpress / Gallery2 (WPG2) Plugin, , WPG2 Documentation, WPG2 Demo

 
bearmeister

Joined: 2008-04-30
Posts: 14
Posted: Tue, 2008-10-07 22:07
Quote:
I have code in the 3.1 development trunk of G2Image that gets the correct sized image by looking at both axes. When we port it to the new "imageblock replacement" in WPG2, it should take care of it correctly. (But like Greg said, it may be a few months before the code gets ported because both of us are busy with real life right now, trying to squeeze in some time to work on this.)

Oh, and "Hi," Stephen Ju! How's it going?

Kirk

Hi capt_kirk & ozgreg,

I have been waiting patiently and diligently for 6 months but my users are still looking at munged up images because they are getting resized within the browser and they look horrid. :( i know you guys have lives and i can appreciate that, i'm just curious if we are likely to have a fix for this bug anytime in the near future? if not - are we able to get a copy of the development code (at our own risk?) that incorporates these bug fixes ? starting to tear my hair out :)

 
lazyzealot

Joined: 2008-11-26
Posts: 1
Posted: Wed, 2008-11-26 19:25

For what it's worth... I've managed to fix this "non-bug" for my site. Basically, I just had it look at the WIDTH only when trying to determine what size to use for my post. You'll need to edit ImageBlockHelper.class located in \modules\imageblock\classes and replace the following code starting around line 424.

/* Get the list of resizes */
$resizes = array();
list ($ret, $ok) = GalleryCoreApi::hasItemPermission(
$derivativeParentId, 'core.viewResizes', $userId);
if ($ret) {
return array($ret, null);
}
if ($ok) {
list ($ret, $resizes) =
GalleryCoreApi::fetchResizesByItemIds(array($image->getId()));
if ($ret) {
return array($ret, null);
}
$resizes = isset($resizes[$derivativeParentId]) ? $resizes[$derivativeParentId]
: array();
}
if (isset($thumbnail)) {
$resizes[] = $thumbnail;
}

foreach ($resizes as $imageObject) {
$rawDifferential = ($imageObject->getWidth() - $maxSize);
if ($biggerOnly && $rawDifferential < 0) {
continue;
}
$resizeDifferential = abs($rawDifferential);
$resizeSize = $imageObject->getWidth();

/*
* If this differential is smaller than the last, update the image target and
* the comparison value.
* If two differentials are equidistant, use the larger based on image size.
*/
if ($resizeDifferential < $imageDifferential
|| $resizeDifferential == $imageDifferential
&& $resizeSize > $imageSize) {
$image = $imageObject;
$imageDifferential = $resizeDifferential;
$imageSize = $resizeSize;
}
}
}

 
bearmeister

Joined: 2008-04-30
Posts: 14
Posted: Thu, 2009-02-12 04:22

correct me if i'm wrong but this is going to work if your target images are landscape?
i think im just going to have to end up finding some other way of skinning this cat.