I'm looking for a php wizard for a tiny job!

This forum is for discussion about anything else.
User avatar
DrippingGoofball
DrippingGoofball
Mafia Piñata
User avatar
User avatar
DrippingGoofball
Mafia Piñata
Mafia Piñata
Posts: 40536
Joined: December 23, 2005
Location: Violating mith's restraining order
Contact:

I'm looking for a php wizard for a tiny job!

Post Post #0 (ISO) » Sun Apr 12, 2020 4:09 pm

Post by DrippingGoofball »

The long and short of it is that there is a form...

The form has two values (
height
of image and
width
of the image that was just uploaded) that need to be automatically plugged in.

Any takers?
Paraphrasing a role PM takes seconds, fabricating a good fakeclaim takes an eternity.

"Metadiving DGB is like playing Roblox" - T3
"She's sort of like a quantum computer, her reads exist in multiple states at once. u have to take into account the other dimensions." - Morning Tweet
User avatar
chamber
chamber
Cases are scummy
User avatar
User avatar
chamber
Cases are scummy
Cases are scummy
Posts: 10703
Joined: November 20, 2005

Post Post #1 (ISO) » Sun Apr 12, 2020 4:27 pm

Post by chamber »

Taking a break from the site.
User avatar
DrippingGoofball
DrippingGoofball
Mafia Piñata
User avatar
User avatar
DrippingGoofball
Mafia Piñata
Mafia Piñata
Posts: 40536
Joined: December 23, 2005
Location: Violating mith's restraining order
Contact:

Post Post #2 (ISO) » Wed Apr 15, 2020 10:30 am

Post by DrippingGoofball »

This is already in the code:

Code: Select all

    function make_thumb($src,$dest,$desired_width) {

         $arr = getimagesize($src);
        /* read the source image */
        switch ($arr['mime']) {
            case 'image/jpeg' : $source_image = imagecreatefromjpeg($src); break;
            case 'image/png' : $source_image = imagecreatefrompng($src); break;
            case 'image/gif' : $source_image = imagecreatefromgif($src); break;
            default: $ext = '';
        }

        $width = imagesx($source_image);
        $height = imagesy($source_image);

           /* find the "desired height" of this thumbnail, relative to the desired width  */
        $desired_height = floor($height*($desired_width/$width));

        /* create a new, "virtual" image */
        $virtual_image = imagecreatetruecolor($desired_width,$desired_height);

        /* copy source image at a resized size */
        imagecopyresized($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height);

           switch ($arr['mime']) {
            case 'image/jpeg' : imagejpeg($virtual_image,$dest); break;
            case 'image/png' : imagepng($virtual_image,$dest); break;
            case 'image/gif' : imagegif($virtual_image,$dest); break;
            default: $ext = '';
        }
        /* create the physical thumbnail image to its destination */
        imagejpeg($virtual_image,$dest);
    }


What I am missing is the values being plugged into the form automatically.

Code: Select all

else if (isset($_GET['print'])) {
    echo '<img src="images/'.$_GET['print'].'" />';
    ?>
    <form action="?printview" method="post">
    <input type="hidden" name="image" value="<?php echo $_GET['print'];?>" />
    <p style="display: none;">Paper size: <select name="format"><option value="letter" selected>Letter</option>
    <option value="a4">A4</option></select></p>
    <br /><p>Ratio: <br />
    <input type="radio" name="ratio" value="yes" checked onClick="manage(this.value);"/>
    <i class="fa fa-lock"  style="font-size:30px"></i>         
    <input type="radio" name="ratio" value="no" onClick="manage(this.value);"/>
    <i class="fa fa-unlock"  style="font-size:30px"></i></p>

    <p  style="display: none;">Image measurements:
    <select name="meassure"><option value="in" selected>inch</option><option value="cm">cm</option></select></p>
    <p>Width (cm):<br /><input type="text" name="width" id="imgwidth" onKeyUp="calc();"/></p>
    <p> <br />Height (cm)<br /><input type="text" name="height" id="imgheight" readonly/></select></p>

    <input type="submit" />
    </form>
    <?php
}
Paraphrasing a role PM takes seconds, fabricating a good fakeclaim takes an eternity.

"Metadiving DGB is like playing Roblox" - T3
"She's sort of like a quantum computer, her reads exist in multiple states at once. u have to take into account the other dimensions." - Morning Tweet
User avatar
chamber
chamber
Cases are scummy
User avatar
User avatar
chamber
Cases are scummy
Cases are scummy
Posts: 10703
Joined: November 20, 2005

Post Post #3 (ISO) » Wed Apr 15, 2020 10:52 am

Post by chamber »

Do you need the thumbnail or source sizes plugged in?
Taking a break from the site.
User avatar
chamber
chamber
Cases are scummy
User avatar
User avatar
chamber
Cases are scummy
Cases are scummy
Posts: 10703
Joined: November 20, 2005

Post Post #4 (ISO) » Wed Apr 15, 2020 11:21 am

Post by chamber »

Looked a bit closer and I assume you want

Code: Select all

<p>Width (cm):<br /><input type="text" name="width" id="imgwidth" onKeyUp="calc();"/></p>
    <p> <br />Height (cm)<br /><input type="text" name="height" id="imgheight" readonly/></select></p
Filled in? But those are in inches or cm, so filling that would require a DPI as well, the value gotten from the function I linked before would be in pixels.
Taking a break from the site.
User avatar
DrippingGoofball
DrippingGoofball
Mafia Piñata
User avatar
User avatar
DrippingGoofball
Mafia Piñata
Mafia Piñata
Posts: 40536
Joined: December 23, 2005
Location: Violating mith's restraining order
Contact:

Post Post #5 (ISO) » Tue Apr 21, 2020 4:17 pm

Post by DrippingGoofball »

Thanks I'll try it.
Paraphrasing a role PM takes seconds, fabricating a good fakeclaim takes an eternity.

"Metadiving DGB is like playing Roblox" - T3
"She's sort of like a quantum computer, her reads exist in multiple states at once. u have to take into account the other dimensions." - Morning Tweet
Post Reply

Return to “General Discussion”