1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Buying Hard programming question...

Discussion in 'Programming' started by Manald, Feb 25, 2014.

  1. #1
    So I have a hard programming question, if anyone can answer this, I will hire you as a coder for my new website!

    Question:

    What does this piece of code do?
    img_src.extend(['/%s' % f for f in glob.glob('static/tmp/'+`pin_id`+'.*.png')])


    Anyone can answer this?! Please PM me the answer or write it here =)

    -Ormus
     
    Manald, Feb 25, 2014 IP
  2. Javed iqbal

    Javed iqbal Well-Known Member

    Messages:
    445
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Hi,
    ultimate image resizer that preserves transparency for gif's and png's and has an option to crop images to fixed dimensions (preserves image proportions by default)

    <?phpfunction image_resize($src, $dst, $width, $height, $crop=0){

    if(!list($w, $h) = getimagesize($src)) return "Unsupported picture type!";

    $type = strtolower(substr(strrchr($src,"."),1));
    if($type == 'jpeg') $type = 'jpg';
    switch($type){
    case 'bmp': $img = imagecreatefromwbmp($src); break;
    case 'gif': $img = imagecreatefromgif($src); break;
    case 'jpg': $img = imagecreatefromjpeg($src); break;
    case 'png': $img = imagecreatefrompng($src); break;
    default : return "Unsupported picture type!";
    }

    // resize
    if($crop){
    if($w < $width or $h < $height) return "Picture is too small!";
    $ratio = max($width/$w, $height/$h);
    $h = $height / $ratio;
    $x = ($w - $width / $ratio) / 2;
    $w = $width / $ratio;
    }
    else{
    if($w < $width and $h < $height) return "Picture is too small!";
    $ratio = min($width/$w, $height/$h);
    $width = $w * $ratio;
    $height = $h * $ratio;
    $x = 0;
    }

    $new = imagecreatetruecolor($width, $height);

    // preserve transparency
    if($type == "gif" or $type == "png"){
    imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127));
    imagealphablending($new, false);
    imagesavealpha($new, true);
    }

    imagecopyresampled($new, $img, 0, 0, $x, 0, $width, $height, $w, $h);

    switch($type){
    case 'bmp': imagewbmp($new, $dst); break;
    case 'gif': imagegif($new, $dst); break;
    case 'jpg': imagejpeg($new, $dst); break;
    case 'png': imagepng($new, $dst); break;
    }
    return true;
    }?>
     
    Javed iqbal, Feb 26, 2014 IP
  3. Javed iqbal

    Javed iqbal Well-Known Member

    Messages:
    445
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    Also if some one developed custom class

    Then this may be function of that class
     
    Javed iqbal, Feb 26, 2014 IP
  4. Javed iqbal

    Javed iqbal Well-Known Member

    Messages:
    445
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    Is it PHP or Python ?????????
     
    Javed iqbal, Feb 26, 2014 IP
  5. imocoder

    imocoder Member

    Messages:
    45
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    Python
     
    imocoder, Feb 26, 2014 IP
  6. bhaskardas

    bhaskardas Active Member

    Messages:
    241
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    ultimate image resizer that preserves transparency for gif's and png's and has an option to crop images to fixed dimensions (preserves image proportions by default)

    Its a python code
     
    bhaskardas, Feb 26, 2014 IP