Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-12-28 04:13:19

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

image resizing (javascript or php?)

I can see some need for having an intermediate size of an image.
I currently have thumbnails (40px square) and the originals (usually about 400px wide by varying heights)

I would like to create a middle size occasionally. A larger thumbnail, but in direct proportion to the original. So a max-height styling with CSS would not cut it.

I have looked around for some Jscript or php that might handle something like this (dynamically), but haven’t found anything yet.

Does anyone have any ideas?

Matthew


Offline

#2 2005-12-28 18:52:37

Jeff_K
Archived Plugin Author
From: Vancouver, British Columbia
Registered: 2005-08-19
Posts: 202
Website

Re: image resizing (javascript or php?)

Take a look at <a href=“http://ca3.php.net/manual/en/function.getimagesize.php”>getimagesize()</a>. You could pretty easily rig something that takes the result and divides it by a constant.

Offline

#3 2005-12-28 19:41:02

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: image resizing (javascript or php?)

It’s already right there in Textpattern’s core code.

Take a look at textpattern/lib/class.thumb.php, these are the functions which are used to build the thumbnails. This module contains a method which writes a scaled image to any file. You can even specify percentages for size reductions and allow/forbid unsquare pixels, i.e. (non-)proportional scaling.

//w&

Last edited by wet (2005-12-28 19:42:25)

Offline

#4 2005-12-29 00:37:56

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: image resizing (javascript or php?)

Wet,
I took a look at the php file, and as usual I am lost, though intrigued :)

I’m not a coder, but hope to continue learning, so, hey, feel like filling me in here? What would the application of what you are talking about look like?
Would I throw a little <code><txp:php>php code here</txp:php></code> in there?

thanks,

matthew


Offline

#5 2005-12-29 07:55:27

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: image resizing (javascript or php?)

I suppose it wouldn’t be that simple as just adding a few lines of txp:php here and there, you might have suspected this yourself as well ;-).

I think that would be a fine addition to the admin side as a plugin extending the “content > image” tab. User interface would imitate the one already present for the thumbnails, and the resulting files would be stored with an additional letter just like the “t” is appended to the thumbnail image filenames by now.
You will definitely learn a lot with that task at hand…

Offline

#6 2005-12-29 13:38:23

squaredeye
Member
From: Greenville, SC
Registered: 2005-07-31
Posts: 1,495
Website

Re: image resizing (javascript or php?)

bq.You will definitely learn a lot with that task at hand…

Yeah, well, probably not :) I’m no where near ready to dive into that one. I’m still learning about expressions and operands and such.

I actually daydreamed the other day that it would be a great txp exercise for some plugin developers to take some would be plugin developers through an easy tutorial or a lesson on plugin dev for txp? pipe dream?

Thanks man,
I’ll save the idea for later.

Matthew


Offline

Board footer

Powered by FluxBB