The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Scaling help
dsmith916
post Nov 29 2014, 07:37 PM
Post #1


Advanced Member
****

Group: Members
Posts: 162
Joined: 5-December 12
Member No.: 18,203



I'm using the following code to display a random image on my tumblr (http://jmdj.tumblr.com) and I'm using iframes to get it on to my theme because you cannot embed php files on another server in your tumblr theme, ive tried.

I'm having a few problems I need help fixing:
1) I want to scale all the images with the php file (http://graylogiclabs.com/JMDJ/tumblr/jmdj_random_pics/rotate.php)

2) the iframe and the images inside it aren't exactly centered and it bugs the hell out of me

#1 is most important, #2 is probably better saved for another topic.

Here's my code (rotate.php)

CODE
<?php
    $folder = '.';
    $extList = array();
    $extList['gif'] = 'image/gif';
    $extList['jpg'] = 'image/jpeg';
    $extList['jpeg'] = 'image/jpeg';
    $extList['png'] = 'image/png';
    

// You don't need to edit anything after this point.


// --------------------- END CONFIGURATION -----------------------

$img = null;

if (substr($folder,-1) != '/') {
    $folder = $folder.'/';
}

if (isset($_GET['img'])) {
    $imageInfo = pathinfo($_GET['img']);
    if (
        isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&
        file_exists( $folder.$imageInfo['basename'] )
    ) {
        $img = $folder.$imageInfo['basename'];
    }
} else {
    $fileList = array();
    $handle = opendir($folder);
    while ( false !== ( $file = readdir($handle) ) ) {
        $file_info = pathinfo($file);
        if (
            isset( $extList[ strtolower( $file_info['extension'] ) ] )
        ) {
            $fileList[] = $file;
        }
    }
    closedir($handle);

    if (count($fileList) > 0) {
        $imageNumber = time() % count($fileList);
        $img = $folder.$fileList[$imageNumber];
    }
}

if ($img!=null) {
    $imageInfo = pathinfo($img);
    $contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
    header ($contentType);
    readfile($img);
} else {
    if ( function_exists('imagecreate') ) {
        header ("Content-type: image/png");
        $im = @imagecreate (100, 100)
            or die ("Cannot initialize new GD image stream");
        $background_color = imagecolorallocate ($im, 255, 255, 255);
        $text_color = imagecolorallocate ($im, 0,0,0);
        imagestring ($im, 2, 5, 5,  "IMAGE ERROR", $text_color);
        imagepng ($im);
        imagedestroy($im);
    }
}

?>


What do I need to add to that code to scale all the images to say 200px width?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Nov 29 2014, 11:34 PM
Post #2


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



QUOTE
I'm using the following code to display a random image on my tumblr (http://jmdj.tumblr.com) and I'm using iframes to get it on to my theme because you cannot embed php files on another server in your tumblr theme, ive tried.


What do you mean by "embedding php" in your theme? If you mean "write php program", then yes, I'm sure that tumblr doesn't run php for you, so it won't work. But I guess that you can "embed" an image, no? In which case there is no need for iframes, you just include an image which you generate with a php program.

It would help if we could see what you are writing in the tumblr thing to access the image.
(The rotate.php program above has no (useful) comments, and I don't want to go through it working out what it's doing, but using the gd library is quite easy.)

For example:
http://www.imaginatorium.org/graphics/irom...x=159&y=124

This is an image (jpeg). Can you include it in your theme? (If not, you just have to change the name to .jpg, and change .htaccess so that jpg files are parsed by php. It is no business of tumblr how a file is being generated!)

You can see what this image does on this page (which is in Japanese, but go to the bottom, and click anywhere on the colour map). This sets the colour scheme, and shows a cursor on the image where you just selected.

http://www.imaginatorium.org/ecco/ecco.htm

HTH
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
dsmith916
post Nov 30 2014, 01:51 PM
Post #3


Advanced Member
****

Group: Members
Posts: 162
Joined: 5-December 12
Member No.: 18,203



QUOTE(Brian Chandler @ Nov 29 2014, 11:34 PM) *

QUOTE
I'm using the following code to display a random image on my tumblr (http://jmdj.tumblr.com) and I'm using iframes to get it on to my theme because you cannot embed php files on another server in your tumblr theme, ive tried.


What do you mean by "embedding php" in your theme? If you mean "write php program", then yes, I'm sure that tumblr doesn't run php for you, so it won't work. But I guess that you can "embed" an image, no? In which case there is no need for iframes, you just include an image which you generate with a php program.

It would help if we could see what you are writing in the tumblr thing to access the image.
(The rotate.php program above has no (useful) comments, and I don't want to go through it working out what it's doing, but using the gd library is quite easy.)

For example:
http://www.imaginatorium.org/graphics/irom...x=159&y=124

This is an image (jpeg). Can you include it in your theme? (If not, you just have to change the name to .jpg, and change .htaccess so that jpg files are parsed by php. It is no business of tumblr how a file is being generated!)

You can see what this image does on this page (which is in Japanese, but go to the bottom, and click anywhere on the colour map). This sets the colour scheme, and shows a cursor on the image where you just selected.

http://www.imaginatorium.org/ecco/ecco.htm

HTH


php does not work in the 'description' field of tumblr. I have tried to use a php include command to insert a php file I have on my server with no success. This is the only way I have been able to get random image rotation to work.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Nov 30 2014, 02:31 PM
Post #4


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



QUOTE
php does not work in the 'description' field of tumblr.


No, I'm sure it doesn't. But what *can* you write in this field? Can you show us what you have written there now? (If you can't, I really don't see how I can help.)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
dsmith916
post Nov 30 2014, 02:45 PM
Post #5


Advanced Member
****

Group: Members
Posts: 162
Joined: 5-December 12
Member No.: 18,203



QUOTE(Brian Chandler @ Nov 30 2014, 02:31 PM) *

QUOTE
php does not work in the 'description' field of tumblr.


No, I'm sure it doesn't. But what *can* you write in this field? Can you show us what you have written there now? (If you can't, I really don't see how I can help.)


here it is:

CODE
<iframe src="http://graylogiclabs.com/JMDJ/tumblr/jmdj_random_pics/rotate.php" frameBorder="0" scrolling="no">Browser not compatible.</iframe>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
dsmith916
post Nov 30 2014, 02:46 PM
Post #6


Advanced Member
****

Group: Members
Posts: 162
Joined: 5-December 12
Member No.: 18,203



The problem I have is if you go to jmdj.tumblr.com on a mobile browser the images don't scale like they do in a web browser. I want to scale all the images to 200px wide via the php code in rotate.php

There are some comments in there but not much help for what I want to do.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Nov 30 2014, 03:03 PM
Post #7


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



So you can include an iframe. Why can't you just include an image? Probably using an iframe increases the problems over resizing etc. (Possibly tumblr will only let you include an image if it "looks" like an image file, by ending in .jpg etc, but really whether a file is an image or not depends on the headers.)

What does rotate.php do, exactly? (Does "rotate" mean random -- how confusing)
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
dsmith916
post Nov 30 2014, 04:54 PM
Post #8


Advanced Member
****

Group: Members
Posts: 162
Joined: 5-December 12
Member No.: 18,203



QUOTE(Brian Chandler @ Nov 30 2014, 03:03 PM) *

So you can include an iframe. Why can't you just include an image? Probably using an iframe increases the problems over resizing etc. (Possibly tumblr will only let you include an image if it "looks" like an image file, by ending in .jpg etc, but really whether a file is an image or not depends on the headers.)

What does rotate.php do, exactly? (Does "rotate" mean random -- how confusing)


yes, it randomly uses one image from a folder and that's what I want to do. I want to be able to drop images in a folder on my sever and have one picked at random.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Dec 1 2014, 03:30 AM
Post #9


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



QUOTE(dsmith916 @ Dec 1 2014, 06:54 AM) *

QUOTE(Brian Chandler @ Nov 30 2014, 03:03 PM) *

So you can include an iframe. Why can't you just include an image? Probably using an iframe increases the problems over resizing etc. (Possibly tumblr will only let you include an image if it "looks" like an image file, by ending in .jpg etc, but really whether a file is an image or not depends on the headers.)

What does rotate.php do, exactly? (Does "rotate" mean random -- how confusing)


yes, it randomly uses one image from a folder and that's what I want to do. I want to be able to drop images in a folder on my sever and have one picked at random.


I think there is some confusion about what "php" means. It's a programming language, and it is not anything that browsers handle. What browsers handle is the *output* of a php program, which is typically an html document, but may equally be a css stylesheet, or a jpeg image. Here the rotate.php program generates a jpeg file -- here are the headers:

Headers for http://graylogiclabs.com/JMDJ/tumblr/jmdj_...pics/rotate.php
HTTP/1.1 200 OK
Date: Mon, 01 Dec 2014 06:39:32 GMT
Server: Apache
Vary: Accept-Encoding
Connection: close
Content-Type: image/jpeg

So first of all, why can you not simply put this jpeg file in your tumblr thingy? Something like:

CODE

<img src="http://graylogiclabs.com/JMDJ/tumblr/jmdj_random_pics/rotate.php">


(Have you tried?)

To get to the business of resizing: why don't you simply resize the photos manually. For exameple irfanview is often mentioned as a good lightweight tool for simple image jobs.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 23rd April 2024 - 12:29 AM