Member
Member
MarcelSpijker   2008-08-06, 14:58
#1

I am trying to make something to displays the histograms.

Now i encounter the following problem:

When i type the next line it shows the image:
`

[img]/marcel/zenphoto/histograms/hist_[/img]

`

When i use the next code it dousnt...

`

$url = getFullImageURL();

$image = basename($url);

$filenaam = "/marcel/zenphoto/histograms/hist_".$image;

if (file_exists($filenaam))

{

echo "

Member
Member
sbillard   2008-08-06, 16:10
#2

The image URL is different from the image filename. Try $image = $_zp_current_image->filename;

Member
Member
MarcelSpijker   2008-08-06, 16:37
#3

There is one thing i forgot to tell:

When i use:
`

if (file_exists($filenaam))

{

echo "

Member
Member
MarcelSpijker   2008-08-06, 17:05
#4

ok, now the site shows correctly, but file_exists still dousnt see the img.

I see the image if i do:
`

$image = $_zp_current_image->filename;

$filenaam = "/marcel/zenphoto/histograms/hist_".$image;

echo "";

`

i do not see the image when i do:
`

$image = $_zp_current_image->filename;

$filenaam = "/marcel/zenphoto/histograms/hist_".$image;

if (file_exists($filenaam))

{

echo "";

}else{

echo "No histogram found.";

}

`
I see only the text: No histogram found.

Member
Member
MarcelSpijker   2008-08-06, 17:18
#5

Well it works, it is (for me) strange:

when i use path:

/marcel/zenphoto/histograms/image.jpg

it shows the image but file_exists dousnt see it!

with file_exists i need to use:

/home/marcelspijker.nl/www/marcel/zenphoto/histograms/image.jpg

And then use the first url to show the image...

Crazy!

But how can i get this so it is usable in a plugin???

Administrator
Administrator
acrylian   2008-08-06, 17:18
#6

Did you try using our constants WEBPATH or FULLWEBPATH?

Member
Member
MarcelSpijker   2008-08-06, 17:45
#7

But WEBPATH and FULLWEBPATH are for the current image yes?

I want to make a plugin that has a folder next to the albums called histograms.
There i want to put all the little histogram files.
And i want it so that when sufing for a picture, the script checks to see if the histogram exist, so he can show that image else he makes one new. So this way i save a lot of server time i think by not creating the image every time.
I hope to put the histogram on the page with something like: PrintHistogram(Option) where option will be a color or black and white histogram. Or even better to select in the admin with every images the option you want...
I am very new with this, so one day i will manage all this i think

Administrator
Administrator
acrylian   2008-08-06, 19:19
#8

WEBPATH and FULLWEBPATH are actually pretty general. On index.php WEBPAHT returns /zenphoto and FULLWEBPATH returns http://www.domain.com/zenphoto. So it should save some work.

We have plugin tutorial on our user guide section.

Member
Member
MarcelSpijker   2008-08-06, 20:39
#9

Thanks! The one i needed was SERVERPATH

That did the trick.

Next problem i have (and i hope somebody can help) is the following:

if i echo the $source_file i see its the right image to make the histogram from,
the script also makes the new images and put it on the page.
But the problem is that its an empty image that only has the background color that you can option for.
I noticed that till $im = ImageCreateFromJpeg($source_file); it works, then the next line $imgw = imagesx($im); here $imgw is empty :S
What is going on?
This should have a value...

The script is started trough the themes image page:
`

$url = getFullImageURL();

hist_makeHistogram($url, "474747");

`

Here is the beginning of the code:
`

function hist_makeHistogram($image, $color)

{

set_time_limit(500);

//HISTOGRAM VARIABLES

global $cfgrow;

$source_file = $cfgrow['imagepath'].$image;

$maxheight = 100;

$barwidth = 1;

$iscolor = false;

$im = ImageCreateFromJpeg($source_file);

$imgw = imagesx($im);

$imgh = imagesy($im);

$n = $imgw*$imgh;

$histo = array();

$histoR = array();

$histoG = array();

$histoB = array();

`

This function is located in plugin dir in file histogram.php and activated by plugintab in admin.

Member
Member
sbillard   2008-08-06, 22:24
#10

what is $cfgrow? $source_file needs to be a fully qualified path to the image. I.e. it needs to have the SERVER_PATH. The errors you are getting indicate that $im is not a valid image object so you probably did not pass the proper file path to ImageCreateFromJpeg.

Just a small note. Since Zenphoto supports image formates other than JPEG you might want to put a test in to see which kind of image you have and use the appropriate ImageCreateFromXXX function.

Member
Member
MarcelSpijker   2008-08-07, 14:06
#11

I will try to make it fully compatible with all the img files zen supports.
But this is just for testing, it is my first php "project" i do, so have a lot to learn
After a night sleep i think i have a hunch with what is wrong, ill test tomorrow, becouse now i have to work till late

Member
Member
MarcelSpijker   2008-08-08, 21:43
#12

Update: It is working now perfectly I now have to cleanup the code and add the png and other extensions to work. shouldn't be to much work.
Thanks all for helping me with my first plugin

To see it in work you can visit my website: http://www.marcelspijker.nl/marcel/zenphoto
Click on a photo and below the photo in the black bar click on the i icon.

Maybe important, the histogram is created the first time somebody looks at the image, it saves it, so the next time somebody looks it will get the histogram from the server. Saves a lot of time. if i created the histograms for all images at one time the server runs out of mem or something...

Member
Member
sbillard   2008-08-08, 22:00
#13

Nice site. I hope you will make your plugin available to the community. (I guess we will have to start a page for third party plugins to support this.)

Administrator
Administrator
acrylian   2008-08-09, 08:52
#14

Marcel, if you provide a download link on your site I will add it to our plugins page (sbillard, we have already a plugins page!). Also you maybe would like to submit your site to the showcase! (btw the links and about pages don't work).

Member
Member
MarcelSpijker   2008-08-09, 09:53
#15

I will make it available! I use Zenphoto with great pleasure, so now i can finaly do something back

I know some links on the site dont work yet, this theme i also just put up, and have yet to make the pages, the archive is also one i have yet to do.

When all is ready, and the plugin clean i will post the plugin and the theme here, so you can put it to the plugin page and the showcase.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.