Development :  K-Meleon Web Browser Forum
K-Meleon development related discussions. 
Picture Zoom
Posted by: Fast Sjonny
Date: March 20, 2004 02:39PM

One of the great futures in KM is the possibility to open a picture in an extra layer and zoom it in. I am using this often but I have one commend about it.
It would be great if the zoom-settings could be changed to for example 1,0 - 1,5 - 2,0 - 2.5 - 3,0 etc.... Now the zoom-factor for most pictures is too big.
Can this be changed?? OR can I change it myself in one of the jar / js etc... files???

Jan.

Options: ReplyQuote
Re: Picture Zoom
Posted by: Fast Sjonny
Date: March 20, 2004 02:51PM

Oeps, already solved it myself and made it 1.25 and .8 instead of the original 2 and .5. For who wants to know it, you can change the settings in the macros.cfg file in your profiledirectory.

Jan.

--------------------------------------------------------------------------------------------------------------------------------

ZoomIn {
menu = "Zoom In";
$FrameURL = "";
$PageURL = $FrameURL;
open("javascript:function chkframes(elem) { var rep; if (decodeURIComponent(elem.location.href) == '".$PageURL."' || '".$PageURL."' == '') { rep = chkimg(elem); if (rep) return rep; } for (var f = 0; f < elem.frames.length; f++) { rep = chkframes(elem.frames[f]); if

(rep) return rep; } return \"\"; } function chkimg(elem) { if (elem.document.images.length > 0) { for (var i = 0; i < elem.document.images.length; i++) { if (elem.document.images.src.indexOf('" .$ImageURL. "') > -1) { return elem.document.images; } } } return \"\"; }

function zoomImage(image, amt) { if (image.initialHeight == null) { /* avoid losing height information due to integer rounding while zooming out */ image.initialHeight = image.height; image.initialWidth = image.width; image.scalingFactor = 1; } image.scalingFactor *=

amt; image.width = image.scalingFactor * image.initialWidth; image.height = image.scalingFactor * image.initialHeight; } function findIMG() { var img = chkframes(window); zoomImage(img,1.25); } void(findIMG());");
}

ZoomOut {
menu = "Zoom Out";
$FrameURL = "";
$PageURL = $FrameURL;
open("javascript:function chkframes(elem) { var rep; if (decodeURIComponent(elem.location.href) == '".$PageURL."' || '".$PageURL."' == '') { rep = chkimg(elem); if (rep) return rep; } for (var f = 0; f < elem.frames.length; f++) { rep = chkframes(elem.frames[f]); if

(rep) return rep; } return \"\"; } function chkimg(elem) { if (elem.document.images.length > 0) { for (var i = 0; i < elem.document.images.length; i++) { if (elem.document.images.src.indexOf('" .$ImageURL. "') > -1) { return elem.document.images; } } } return \"\"; }

function zoomImage(image, amt) { if (image.initialHeight == null) { /* avoid losing height information due to integer rounding while zooming out */ image.initialHeight = image.height; image.initialWidth = image.width; image.scalingFactor = 1; } image.scalingFactor *=

amt; image.width = image.scalingFactor * image.initialWidth; image.height = image.scalingFactor * image.initialHeight; } function findIMG() { var img = chkframes(window); zoomImage(img, .8); } void(findIMG());");
}


Options: ReplyQuote
Re: Picture Zoom
Posted by: Fast Sjonny
Date: March 20, 2004 03:11PM

And I found a little error. When I used the macro's ZoomIn and ZoomOut with acceleratorkeys I got the message ImageURL not declared.
I solved it by adding two rows:

For ZoomIn (4th row):

ZoomIn {
menu = "Zoom In";
$FrameURL = "";
$ImageURL = "";
$PageURL = $FrameURL; etc......

For ZoomOut the same (4th row):

ZoomOut {
menu = "Zoom Out";
$FrameURL = "";
$ImageURL = "";
$PageURL = $FrameURL; etc......


Everything is working fine now.

Greeetzzzzz,
Jan.

Options: ReplyQuote
Re: Picture Zoom
Posted by: Fast Sjonny
Date: March 20, 2004 03:27PM

Next time I will try to do it in one post but as I mentioned I have added two accelerators for the Zoom-function also in accel.cfg.

1. So, in short again, I have changed the zoom-factors in Macros.cfg to 1.25 and .8
Find the ZoomIn and ZoomOut macros in macros.cfg and change the following part:

For ZoomIn:
w); zoomImage(img,1.25); } void(findIMG());");
}

For ZoomOut:
ow); zoomImage(img, .8); } void(findIMG());");
}


2. Then I solved the errormessage when using the macro in combination with the acceleratorkeys because of a missing declaration. Add the following:

$ImageURL = "";

Like I did:

ZoomIn {
menu = "Zoom In";
$FrameURL = "";
$ImageURL = "";

ZoomOut {
menu = "Zoom Out";
$FrameURL = "";
$ImageURL = "";


3. And I added the two accelerator-keysettings, so control-shift-plus is zoomin, control-shift-minus is zoomout. Add the following in accel.cfg:

CTRL SHIFT VK_PLUS = macros(ZoomIn)
CTRL SHIFT VK_MINUS = macros(ZoomOut)

Jan.

Options: ReplyQuote
Re: Picture Zoom
Posted by: SlideRule
Date: March 20, 2004 04:16PM

Fast Sjonny:

I really like your modifications/improvements to the "Image Zoom In" and "Image Zoom Out" capabilities of K-Meleon.

I would also suggest, an addition . . . adding two more items to the accel.cfg file. That is, the 'changes' to the accel.cfg file should be:

CTRL SHIFT VK_PLUS = macros(ZoomIn)
CTRL SHIFT VK_ADD = macros(ZoomIn)
CTRL SHIFT VK_MINUS = macros(ZoomOut)
CTRL SHIFT VK_SUBTRACT = macros(ZoomOut)

so, not only will the plus and minus keys near the 'alpha' keys activate the macro, but, alternatively, the add ( + ) and subtract ( - ) keys on the 'keypad' will also activate the macros.

SlideRule

Options: ReplyQuote
Re: Picture Zoom
Posted by: Fast Sjonny
Date: March 20, 2004 05:06PM

Good point ;-))

Options: ReplyQuote
Re: Picture Zoom
Posted by: Marc (@box.)
Date: March 21, 2004 06:25PM

Fast Sjonny wrote:
> 2. Then I solved the errormessage when using the macro in
> combination with the acceleratorkeys because of a missing
> declaration. Add the following:
>
> $ImageURL = "";
> 3. And I added the two accelerator-keysettings, so
> control-shift-plus is zoomin, control-shift-minus is zoomout.
> Add the following in accel.cfg:

What's the point for adding accelerators for zoom-in and zoom-out?
These js macros will only work if an image url is given. So these 2 modifications are pointless.

Options: ReplyQuote
Re: Picture Zoom
Posted by: Fast Sjonny
Date: March 22, 2004 04:14PM

Hi Marc,

You are right about that, I had the same feeling.
But, when I open a picture in a new layer, I get the errormessage as I descriped above. With the add $ImageURL = "" this message is gone and everything is working fine.
So, don't ask me why, but this combi is working great on my computer.
May be you have ideas about it???

Jan.

Options: ReplyQuote
Re: Picture Zoom
Posted by: jsnj
Date: March 22, 2004 08:04PM
Options: ReplyQuote
Re: Picture Zoom
Posted by: jsnj
Date: March 22, 2004 08:05PM

But, when I open a picture in a new layer, I get the errormessage as I descriped above.

Just use this macro. That'll serve you well for that feature. Also, it'll allow you to zoom in & out of all images on any given page.

Options: ReplyQuote
Re: Picture Zoom
Posted by: Fast Sjonny
Date: March 22, 2004 10:15PM

Hi jsnj,

I copied the macro's from the link into my macro's like this:

ZoomIn{
open("javascriptsad smileyfunction(){ function zoomImage(image, amt) { if(image.initialHeight == null) { /* avoid losing height information due to integer rounding while zooming out */ image.initialHeight = image.height; image.initialWidth = image.width; image.scalingFactor = 1;

} image.scalingFactor *= amt; image.width = image.scalingFactor * image.initialWidth; image.height = image.scalingFactor * image.initialHeight; } for (i=0; i<document.images.length; ++i) zoomImage(document.images, 1.25); })();");
}

ZoomOut{
open("javascriptsad smileyfunction(){ function zoomImage(image, amt) { if(image.initialHeight == null) { /* avoid losing height information due to integer rounding while zooming out */ image.initialHeight = image.height; image.initialWidth = image.width; image.scalingFactor = 1;

} image.scalingFactor *= amt; image.width = image.scalingFactor * image.initialWidth; image.height = image.scalingFactor * image.initialHeight; } for (i=0; i<document.images.length; ++i) zoomImage(document.images, .8); })();");
}

And it is working fine.
What I don't understand; why aren't these the standard macro's and why do I have to find this out this way??????
Doesn't mather, thanks for your help and I think I will keep with these now.

Jan.


Options: ReplyQuote
Re: Picture Zoom
Posted by: jsnj
Date: March 22, 2004 10:48PM

What I don't understand; why aren't these the standard macro's and why do I have to find this out this way??????

Well, as far as I know the Zoom In & Zoom Out selected image features aren't standard in any browser. K-Meleon is the only one I know of to have them available immediately after installation. The Zoom In & Out All images macros have been available in the macros library since May 2003. It's my understanding that the developers' intent is not to bloat K-Meleon's download file with every conceivable macro available. That's what the macro library is for. :-) More macros may be available by default in KM's next release depending on what the popular requests are and what may be included in the core.

Options: ReplyQuote
Re: Picture Zoom
Posted by: Marc (@box.)
Date: March 23, 2004 02:43PM

Fast Sjonny wrote:
> You are right about that, I had the same feeling.
> But, when I open a picture in a new layer, I get the
> errormessage as I descriped above.
So you have a picture opened in a layer (not within an html tag). And you have the standard zoom macro displaying an error message when you right-click the image and select zoom ? Is that what you say ?
I'm using the latest version of the zoom macros (from 0.8.2) and have no problem

> With the add $ImageURL =
> "" this message is gone and everything is working fine.
The thing you don't understand is that the js code (I know what it does since I'm the guy who extended it to work with frames) won't zoom any image if no image url (or an empty one) is given.

> So, don't ask me why, but this combi is working great on my
> computer.
> May be you have ideas about it???

No idea why it works. Do you have an example? Screenshot before and after you've used the keyboard shortcut.

Options: ReplyQuote
Re: Picture Zoom
Posted by: Fast Sjonny
Date: March 23, 2004 02:56PM

Right mouse button is working fine without the add $ImageURL = "" but shortkeys giving an error. When I used the ctrl-shft-add or minus I got the errormessage missing declaration etc... With this add the problem was solved.
At this moment I am using the macro's as jsnj mentioned and these are working without any problem.

As you told, the macro is working fine in 0.8.2., same for me.
Problem was working with accel.cfg and shortkeys for the ZoomIn and ZoomOut.
Therefor I added the $ImageURL = "", but I do not need that for the macro jsnj mentioned. That one is working fine without.

Jan

Options: ReplyQuote
Re: Picture Zoom
Posted by: Marc (@box.)
Date: March 23, 2004 04:54PM

Fast Sjonny wrote:
> As you told, the macro is working fine in 0.8.2., same for me.
> Problem was working with accel.cfg and shortkeys for the
> ZoomIn and ZoomOut.
> Therefor I added the $ImageURL = "", but I do not need that
> for the macro jsnj mentioned. That one is working fine without.

But when do you use the shorcut, and what does it do ?

Options: ReplyQuote
Re: Picture Zoom
Posted by: Fast Sjonny
Date: March 23, 2004 07:44PM

What do you mean?? I thought I had explained it already, so I don't know which part is not fully clear.. Sorry, maybe because of my bad english...

Jan

Options: ReplyQuote
Re: Picture Zoom
Posted by: jsnj
Date: March 23, 2004 08:48PM

I know what it does since I'm the guy who extended it to work with frames.

Marc, can the Open Image Links macro be made to work within frames? I tried to sort of mirror what was done with the Zoom macros but couldn't get it to work. This page is an example of where it doesn't work. But if you open the frame and then use it, it works.

Options: ReplyQuote
Re: Picture Zoom
Posted by: jsnj
Date: March 23, 2004 08:57PM

Oops, the link didn't work again:

http://www.btinternet.com/~prudhoe/gm1.htm

BTW, it's just a random site I found to use as an example. I have no idea who those people are :-)

Options: ReplyQuote
Re: Picture Zoom
Posted by: Marc (@box.)
Date: March 24, 2004 02:44AM

jsnj wrote:
> Marc, can the Open Image Links macro be made to work within frames?
> I tried to sort of mirror what was done with the Zoom macros but couldn't get it to work.

I'll look at it tomorrow.
Do you want it to work for all the frames displayed, or only for the selected frame ?

Options: ReplyQuote
Re: Picture Zoom
Posted by: Marc (@box.)
Date: March 24, 2004 02:45AM

Fast Sjonny wrote:
> What do you mean?? I thought I had explained it already, so I
> don't know which part is not fully clear.. Sorry, maybe
> because of my bad english...

In fact I was basing my assumptions by using _my_ code with the accelerators. And nothing is zoomed. But when using your code, which is older than mine, the first image of the page is zoomed.
Unfortunately, the newer version doesn't allow this. It uses a stricter method to match the correct image url (in some circumstances with the old code the wrong image was zoomed), and won't match anything with an empty line.

If you can tell me when you use the shortcuts, I can try to modify the new code to also work in your situation.
- do you use it on a page like this one (KM forum) to zoom the first image ?
- on a page which contains only one image, but is still an html document (using

Options: ReplyQuote
Re: Picture Zoom
Posted by: jsnj
Date: March 24, 2004 03:07AM

I'll look at it tomorrow.
Do you want it to work for all the frames displayed, or only for the selected frame ?


Thanks. Well, for all the frames displayed would be great since I usually use a mouse gesture to activate it, but if that's not possible then the selected frame would be better than the way it is now. The way it is now, within frames the macro just produces a blank page.

Options: ReplyQuote
Re: Picture Zoom
Posted by: Fast Sjonny
Date: March 24, 2004 06:52AM

Ahh Marc, now I understand what you mean.
What I normally do is opening the picture in his own window.
There everything is working fine and that's the way I wanted it to work

Jan.

Options: ReplyQuote
Re: Picture Zoom
Posted by: Fast Sjonny
Date: March 26, 2004 09:15AM

Hi Marc,

I was curious if you understand my explanation and if you already have done something with it. May be it is something to make default in the new 0.9 ??

Jan.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.