Jump to content

sprintlife

Members
  • Posts

    29
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

sprintlife's Achievements

Member

Member (2/5)

0

Reputation

  1. I've done either one. I've done the QuoteID and quite_id. Neither one works. :-(
  2. Thanks, but it still doesn't work. I had a php doing the json, but it keep not working go I wrote the code out. I keep getting this error
  3. I haven't post here in sometime, but I'm having issue. I cant get ahold of the people that made this API so I figure I would give you guys a go. I keep getting error when running this code. Error message is ( Exception raised in parsing - too many parameters - not even bothering to parse ). <!DOCTYPE HTML> <html> <head> <title></title> </head> <body> <?php $data_string = "{\"quote_id\":\"09b1de5a-090d-45bc-87b1-e11f44570b3c\",\"URL\":\"http://test.com/test.php\",\"Secret\":\"15b1370f-4130-4123-a3ab-bce5e174d9cd\"}"; $ch = curl_init('https://www.bitinstant.com/api/json/SetOrderIPN'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data_string)) ); $result = curl_exec($ch); echo $result; ?> </body> </html> I'm trying to run an API on the SetOrderIPN on ( https://www.bitinstant.com/api ). This is the information they have on it. I was wondering if anyone could point out what I am doing wrong. :-( I got the source code from this location ( https://bitcointalk.org/index.php?topic=117740.msg1526313#msg1526313 ), but their were using it to place quote ( GetQuote ).
  4. I did this to fix it... SELECT SUM(MONTH(FROM_UNIXTIME(timestamp)) = '01' AND YEAR(FROM_UNIXTIME(timestamp)) = $year) AS numjan, SUM(MONTH(FROM_UNIXTIME(timestamp)) = '02' AND YEAR(FROM_UNIXTIME(timestamp)) = $year) AS numfen, SUM(MONTH(FROM_UNIXTIME(timestamp)) = '03' AND YEAR(FROM_UNIXTIME(timestamp)) = $year) AS nummar, SUM(MONTH(FROM_UNIXTIME(timestamp)) = '04' AND YEAR(FROM_UNIXTIME(timestamp)) = $year) AS numapr, SUM(MONTH(FROM_UNIXTIME(timestamp)) = '05' AND YEAR(FROM_UNIXTIME(timestamp)) = $year) AS nummay, SUM(MONTH(FROM_UNIXTIME(timestamp)) = '06' AND YEAR(FROM_UNIXTIME(timestamp)) = $year) AS numjun, SUM(MONTH(FROM_UNIXTIME(timestamp)) = '07' AND YEAR(FROM_UNIXTIME(timestamp)) = $year) AS numjul, SUM(MONTH(FROM_UNIXTIME(timestamp)) = '08' AND YEAR(FROM_UNIXTIME(timestamp)) = $year) AS numaug, SUM(MONTH(FROM_UNIXTIME(timestamp)) = '09' AND YEAR(FROM_UNIXTIME(timestamp)) = $year) AS numsep, SUM(MONTH(FROM_UNIXTIME(timestamp)) = '10' AND YEAR(FROM_UNIXTIME(timestamp)) = $year) AS numout, SUM(MONTH(FROM_UNIXTIME(timestamp)) = '11' AND YEAR(FROM_UNIXTIME(timestamp)) = $year) AS numnov, SUM(MONTH(FROM_UNIXTIME(timestamp)) = '12' AND YEAR(FROM_UNIXTIME(timestamp)) = $year) AS numdec FROM memorial_page If you guys know any better way to do it I would love to hear it.
  5. Okay so a good friend did this for me /* $memorial = mysql_numrows($database->query("SELECT id FROM users WHERE userlevel ='0'")); $fhdirector = mysql_numrows($database->query("SELECT id FROM users WHERE userlevel ='1'")); $nonprofile = mysql_numrows($database->query("SELECT id FROM users WHERE userlevel ='2'")); $sales = mysql_numrows($database->query("SELECT id FROM users WHERE userlevel ='3'")); $support = mysql_numrows($database->query("SELECT id FROM users WHERE userlevel ='4'")); $admin = mysql_numrows($database->query("SELECT id FROM users WHERE userlevel ='5'")); */ $SQL = " SELECT SUM(IF(userlevel='0',1,0)) AS numMemorial, SUM(IF(userlevel='1',1,0)) AS numFHDirector, SUM(IF(userlevel='2',1,0)) AS numNonProfile, SUM(IF(userlevel='3',1,0)) AS numSales, SUM(IF(userlevel='4',1,0)) AS numSupport, SUM(IF(userlevel='5',1,0)) AS numAdmin FROM users"; $result = $database->query($SQL); foreach (mysql_fetch_assoc($result) as $key => $value) { $$key = intval($value); //force string to an integer value } I am trying to do the same thing but with this table /* $jan = mysql_numrows($database->query("SELECT id FROM memorial_page WHERE MONTH(FROM_UNIXTIME(timestamp)) = 01 AND YEAR(FROM_UNIXTIME(timestamp)) = $year")); $fen = mysql_numrows($database->query("SELECT id FROM memorial_page WHERE MONTH(FROM_UNIXTIME(timestamp)) = 02 AND YEAR(FROM_UNIXTIME(timestamp)) = $year")); $mar = mysql_numrows($database->query("SELECT id FROM memorial_page WHERE MONTH(FROM_UNIXTIME(timestamp)) = 03 AND YEAR(FROM_UNIXTIME(timestamp)) = $year")); $apr = mysql_numrows($database->query("SELECT id FROM memorial_page WHERE MONTH(FROM_UNIXTIME(timestamp)) = 04 AND YEAR(FROM_UNIXTIME(timestamp)) = $year")); $may = mysql_numrows($database->query("SELECT id FROM memorial_page WHERE MONTH(FROM_UNIXTIME(timestamp)) = 05 AND YEAR(FROM_UNIXTIME(timestamp)) = $year")); $jun = mysql_numrows($database->query("SELECT id FROM memorial_page WHERE MONTH(FROM_UNIXTIME(timestamp)) = 06 AND YEAR(FROM_UNIXTIME(timestamp)) = $year")); $jul = mysql_numrows($database->query("SELECT id FROM memorial_page WHERE MONTH(FROM_UNIXTIME(timestamp)) = 07 AND YEAR(FROM_UNIXTIME(timestamp)) = $year")); $aug = mysql_numrows($database->query("SELECT id FROM memorial_page WHERE MONTH(FROM_UNIXTIME(timestamp)) = 08 AND YEAR(FROM_UNIXTIME(timestamp)) = $year")); $sep = mysql_numrows($database->query("SELECT id FROM memorial_page WHERE MONTH(FROM_UNIXTIME(timestamp)) = 09 AND YEAR(FROM_UNIXTIME(timestamp)) = $year")); $out = mysql_numrows($database->query("SELECT id FROM memorial_page WHERE MONTH(FROM_UNIXTIME(timestamp)) = 10 AND YEAR(FROM_UNIXTIME(timestamp)) = $year")); $nov = mysql_numrows($database->query("SELECT id FROM memorial_page WHERE MONTH(FROM_UNIXTIME(timestamp)) = 11 AND YEAR(FROM_UNIXTIME(timestamp)) = $year")); $dec = mysql_numrows($database->query("SELECT id FROM memorial_page WHERE MONTH(FROM_UNIXTIME(timestamp)) = 12 AND YEAR(FROM_UNIXTIME(timestamp)) = $year")); */ $SQL2 = " SELECT SUM(IF(MONTH(FROM_UNIXTIME(timestamp))='01',1,0)) AND YEAR(FROM_UNIXTIME(timestamp)) = $year AS jan, SUM(IF(MONTH(FROM_UNIXTIME(timestamp))='02',1,0)) AND YEAR(FROM_UNIXTIME(timestamp)) = $year AS fen, SUM(IF(MONTH(FROM_UNIXTIME(timestamp))='03',1,0)) AND YEAR(FROM_UNIXTIME(timestamp)) = $year AS mar, SUM(IF(MONTH(FROM_UNIXTIME(timestamp))='04',1,0)) AND YEAR(FROM_UNIXTIME(timestamp)) = $year AS apr, SUM(IF(MONTH(FROM_UNIXTIME(timestamp))='05',1,0)) AND YEAR(FROM_UNIXTIME(timestamp)) = $year AS may, SUM(IF(MONTH(FROM_UNIXTIME(timestamp))='06',1,0)) AND YEAR(FROM_UNIXTIME(timestamp)) = $year AS jun, SUM(IF(MONTH(FROM_UNIXTIME(timestamp))='07',1,0)) AND YEAR(FROM_UNIXTIME(timestamp)) = $year AS jul, SUM(IF(MONTH(FROM_UNIXTIME(timestamp))='08',1,0)) AND YEAR(FROM_UNIXTIME(timestamp)) = $year AS aug, SUM(IF(MONTH(FROM_UNIXTIME(timestamp))='09',1,0)) AND YEAR(FROM_UNIXTIME(timestamp)) = $year AS sep, SUM(IF(MONTH(FROM_UNIXTIME(timestamp))='10',1,0)) AND YEAR(FROM_UNIXTIME(timestamp)) = $year AS out, SUM(IF(MONTH(FROM_UNIXTIME(timestamp))='11',1,0)) AND YEAR(FROM_UNIXTIME(timestamp)) = $year AS nov, SUM(IF(MONTH(FROM_UNIXTIME(timestamp))='12',1,0)) AND YEAR(FROM_UNIXTIME(timestamp)) = $year AS dec FROM memorial_page"; $result2 = $database->query($SQL2); foreach (mysql_fetch_assoc($result2) as $key => $value) { // The error message below is talking about this line $$key = intval($value); //force string to an integer value } If anyone can example to me what I am doing wrong is. Here is the error message I get [15-May-2009 03:48:34] PHP Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/tyslo/public_html/file/panel/charts/admin.php on line 102 [15-May-2009 03:48:34] PHP Warning: Invalid argument supplied for foreach() in /home/tyslo/public_html/file/panel/charts/admin.php on line 102 So if anyone can help me out that would be great.
  6. Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/tylslo/public_html/siteurl/panel/include/functions/thumbnail.php on line 686 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/tylslo/public_html/siteurl/panel/include/functions/thumbnail.php on line 691 Those errors are this line $this->workingImage = ImageCreateTrueColor($newImageWidth,$newImageHeight); and imagecopyresampled($this->workingImage,$this->oldImage,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$newImageWidth,$height);
  7. I am trying to put that function in that class. What I wanna do is use the Jquery feature to redo the thumbnails.
  8. What I am trying to do is combine this http://www.webmotionuk.co.uk/jquery-image-upload-and-crop-for-php/ with this http://www.gen-x-design.com/projects/php-thumbnailer-class/
  9. This is the function. function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale){ list($imagewidth, $imageheight, $imageType) = getimagesize($image); $imageType = image_type_to_mime_type($imageType); $newImageWidth = ceil($width * $scale); $newImageHeight = ceil($height * $scale); $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight); switch($imageType) { case "image/gif": $source=imagecreatefromgif($image); break; case "image/pjpeg": case "image/jpeg": case "image/jpg": $source=imagecreatefromjpeg($image); break; case "image/png": case "image/x-png": $source=imagecreatefrompng($image); break; } imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$width,$height); switch($imageType) { case "image/gif": imagegif($newImage,$thumb_image_name); break; case "image/pjpeg": case "image/jpeg": case "image/jpg": imagejpeg($newImage,$thumb_image_name,90); break; case "image/png": case "image/x-png": imagepng($newImage,$thumb_image_name); break; } chmod($thumb_image_name, 0777); return $thumb_image_name; } This is the class class Thumbnail { /** * Error message to display, if any * * @var string */ private $errmsg; /** * Whether or not there is an error * * @var boolean */ private $error; /** * Format of the image file * * @var string */ private $format; /** * File name and path of the image file * * @var string */ private $fileName; /** * Image meta data if any is available (jpeg/tiff) via the exif library * * @var array */ public $imageMeta; /** * Current dimensions of working image * * @var array */ private $currentDimensions; /** * New dimensions of working image * * @var array */ private $newDimensions; /** * Image resource for newly manipulated image * * @var resource */ private $newImage; /** * Image resource for image before previous manipulation * * @var resource */ private $oldImage; /** * Image resource for image being currently manipulated * * @var resource */ private $workingImage; /** * Percentage to resize image by * * @var int */ private $percent; /** * Maximum width of image during resize * * @var int */ private $maxWidth; /** * Maximum height of image during resize * * @var int */ private $maxHeight; /** * Class constructor * * @param string $fileName * @return Thumbnail */ public function __construct($fileName) { //make sure the GD library is installed if(!function_exists("gd_info")) { echo 'You do not have the GD Library installed. This class requires the GD library to function properly.' . "\n"; echo 'visit http://us2.php.net/manual/en/ref.image.php for more information'; exit; } //initialize variables $this->errmsg = ''; $this->error = false; $this->currentDimensions = array(); $this->newDimensions = array(); $this->fileName = $fileName; $this->imageMeta = array(); $this->percent = 100; $this->maxWidth = 0; $this->maxHeight = 0; //check to see if file exists if(!file_exists($this->fileName)) { $this->errmsg = 'File not found'; $this->error = true; } //check to see if file is readable elseif(!is_readable($this->fileName)) { $this->errmsg = 'File is not readable'; $this->error = true; } //if there are no errors, determine the file format if($this->error == false) { //check if gif if(stristr(strtolower($this->fileName),'.gif')) $this->format = 'GIF'; //check if jpg elseif(stristr(strtolower($this->fileName),'.jpg') || stristr(strtolower($this->fileName),'.jpeg')) $this->format = 'JPG'; //check if png elseif(stristr(strtolower($this->fileName),'.png')) $this->format = 'PNG'; //unknown file format else { $this->errmsg = 'Unknown file format'; $this->error = true; } } //initialize resources if no errors if($this->error == false) { switch($this->format) { case 'GIF': $this->oldImage = ImageCreateFromGif($this->fileName); break; case 'JPG': $this->oldImage = ImageCreateFromJpeg($this->fileName); break; case 'PNG': $this->oldImage = ImageCreateFromPng($this->fileName); break; } $size = GetImageSize($this->fileName); $this->currentDimensions = array('width'=>$size[0],'height'=>$size[1]); $this->newImage = $this->oldImage; $this->gatherImageMeta(); } if($this->error == true) { $this->showErrorImage(); break; } } /** * Class destructor * */ public function __destruct() { if(is_resource($this->newImage)) @ImageDestroy($this->newImage); if(is_resource($this->oldImage)) @ImageDestroy($this->oldImage); if(is_resource($this->workingImage)) @ImageDestroy($this->workingImage); } /** * Returns the current width of the image * * @return int */ public function getCurrentWidth() { return $this->currentDimensions['width']; } /** * Returns the current height of the image * * @return int */ public function getCurrentHeight() { return $this->currentDimensions['height']; } /** * Calculates new image width * * @param int $width * @param int $height * @return array */ private function calcWidth($width,$height) { $newWp = (100 * $this->maxWidth) / $width; $newHeight = ($height * $newWp) / 100; return array('newWidth'=>intval($this->maxWidth),'newHeight'=>intval($newHeight)); } /** * Calculates new image height * * @param int $width * @param int $height * @return array */ private function calcHeight($width,$height) { $newHp = (100 * $this->maxHeight) / $height; $newWidth = ($width * $newHp) / 100; return array('newWidth'=>intval($newWidth),'newHeight'=>intval($this->maxHeight)); } /** * Calculates new image size based on percentage * * @param int $width * @param int $height * @return array */ private function calcPercent($width,$height) { $newWidth = ($width * $this->percent) / 100; $newHeight = ($height * $this->percent) / 100; return array('newWidth'=>intval($newWidth),'newHeight'=>intval($newHeight)); } /** * Calculates new image size based on width and height, while constraining to maxWidth and maxHeight * * @param int $width * @param int $height */ private function calcImageSize($width,$height) { $newSize = array('newWidth'=>$width,'newHeight'=>$height); if($this->maxWidth > 0) { $newSize = $this->calcWidth($width,$height); if($this->maxHeight > 0 && $newSize['newHeight'] > $this->maxHeight) { $newSize = $this->calcHeight($newSize['newWidth'],$newSize['newHeight']); } //$this->newDimensions = $newSize; } if($this->maxHeight > 0) { $newSize = $this->calcHeight($width,$height); if($this->maxWidth > 0 && $newSize['newWidth'] > $this->maxWidth) { $newSize = $this->calcWidth($newSize['newWidth'],$newSize['newHeight']); } //$this->newDimensions = $newSize; } $this->newDimensions = $newSize; } /** * Calculates new image size based percentage * * @param int $width * @param int $height */ private function calcImageSizePercent($width,$height) { if($this->percent > 0) { $this->newDimensions = $this->calcPercent($width,$height); } } /** * Displays error image * */ private function showErrorImage() { header('Content-type: image/png'); $errImg = ImageCreate(220,25); $bgColor = imagecolorallocate($errImg,0,0,0); $fgColor1 = imagecolorallocate($errImg,255,255,255); $fgColor2 = imagecolorallocate($errImg,255,0,0); imagestring($errImg,3,6,6,'Error:',$fgColor2); imagestring($errImg,3,55,6,$this->errmsg,$fgColor1); imagepng($errImg); imagedestroy($errImg); } /** * Resizes image to maxWidth x maxHeight * * @param int $maxWidth * @param int $maxHeight */ public function resize($maxWidth = 0, $maxHeight = 0) { $this->maxWidth = $maxWidth; $this->maxHeight = $maxHeight; $this->calcImageSize($this->currentDimensions['width'],$this->currentDimensions['height']); if(function_exists("ImageCreateTrueColor")) { $this->workingImage = ImageCreateTrueColor($this->newDimensions['newWidth'],$this->newDimensions['newHeight']); } else { $this->workingImage = ImageCreate($this->newDimensions['newWidth'],$this->newDimensions['newHeight']); } ImageCopyResampled( $this->workingImage, $this->oldImage, 0, 0, 0, 0, $this->newDimensions['newWidth'], $this->newDimensions['newHeight'], $this->currentDimensions['width'], $this->currentDimensions['height'] ); $this->oldImage = $this->workingImage; $this->newImage = $this->workingImage; $this->currentDimensions['width'] = $this->newDimensions['newWidth']; $this->currentDimensions['height'] = $this->newDimensions['newHeight']; } /** * Resizes the image by $percent percent * * @param int $percent */ public function resizePercent($percent = 0) { $this->percent = $percent; $this->calcImageSizePercent($this->currentDimensions['width'],$this->currentDimensions['height']); if(function_exists("ImageCreateTrueColor")) { $this->workingImage = ImageCreateTrueColor($this->newDimensions['newWidth'],$this->newDimensions['newHeight']); } else { $this->workingImage = ImageCreate($this->newDimensions['newWidth'],$this->newDimensions['newHeight']); } ImageCopyResampled( $this->workingImage, $this->oldImage, 0, 0, 0, 0, $this->newDimensions['newWidth'], $this->newDimensions['newHeight'], $this->currentDimensions['width'], $this->currentDimensions['height'] ); $this->oldImage = $this->workingImage; $this->newImage = $this->workingImage; $this->currentDimensions['width'] = $this->newDimensions['newWidth']; $this->currentDimensions['height'] = $this->newDimensions['newHeight']; } /** * Crops the image from calculated center in a square of $cropSize pixels * * @param int $cropSize */ public function cropFromCenter($cropSize) { if($cropSize > $this->currentDimensions['width']) $cropSize = $this->currentDimensions['width']; if($cropSize > $this->currentDimensions['height']) $cropSize = $this->currentDimensions['height']; $cropX = intval(($this->currentDimensions['width'] - $cropSize) / 2); $cropY = intval(($this->currentDimensions['height'] - $cropSize) / 2); if(function_exists("ImageCreateTrueColor")) { $this->workingImage = ImageCreateTrueColor($cropSize,$cropSize); } else { $this->workingImage = ImageCreate($cropSize,$cropSize); } imagecopyresampled( $this->workingImage, $this->oldImage, 0, 0, $cropX, $cropY, $cropSize, $cropSize, $cropSize, $cropSize ); $this->oldImage = $this->workingImage; $this->newImage = $this->workingImage; $this->currentDimensions['width'] = $cropSize; $this->currentDimensions['height'] = $cropSize; } /** * Advanced cropping function that crops an image using $startX and $startY as the upper-left hand corner. * * @param int $startX * @param int $startY * @param int $width * @param int $height */ public function crop($startX,$startY,$width,$height) { //make sure the cropped area is not greater than the size of the image if($width > $this->currentDimensions['width']) $width = $this->currentDimensions['width']; if($height > $this->currentDimensions['height']) $height = $this->currentDimensions['height']; //make sure not starting outside the image if(($startX + $width) > $this->currentDimensions['width']) $startX = ($this->currentDimensions['width'] - $width); if(($startY + $height) > $this->currentDimensions['height']) $startY = ($this->currentDimensions['height'] - $height); if($startX < 0) $startX = 0; if($startY < 0) $startY = 0; if(function_exists("ImageCreateTrueColor")) { $this->workingImage = ImageCreateTrueColor($width,$height); } else { $this->workingImage = ImageCreate($width,$height); } imagecopyresampled( $this->workingImage, $this->oldImage, 0, 0, $startX, $startY, $width, $height, $width, $height ); $this->oldImage = $this->workingImage; $this->newImage = $this->workingImage; $this->currentDimensions['width'] = $width; $this->currentDimensions['height'] = $height; } /** * Outputs the image to the screen, or saves to $name if supplied. Quality of JPEG images can be controlled with the $quality variable * * @param int $quality * @param string $name */ public function show($quality=100,$name = '') { switch($this->format) { case 'GIF': if($name != '') { ImageGif($this->newImage,$name); } else { header('Content-type: image/gif'); ImageGif($this->newImage); } break; case 'JPG': if($name != '') { ImageJpeg($this->newImage,$name,$quality); } else { header('Content-type: image/jpeg'); ImageJpeg($this->newImage,'',$quality); } break; case 'PNG': if($name != '') { ImagePng($this->newImage,$name); } else { header('Content-type: image/png'); ImagePng($this->newImage); } break; } } /** * Saves image as $name (can include file path), with quality of # percent if file is a jpeg * * @param string $name * @param int $quality */ public function save($name,$quality=100) { $this->show($quality,$name); } /** * Creates Apple-style reflection under image, optionally adding a border to main image * * @param int $percent * @param int $reflection * @param int $white * @param bool $border * @param string $borderColor */ public function createReflection($percent,$reflection,$white,$border = true,$borderColor = '#a4a4a4') { $width = $this->currentDimensions['width']; $height = $this->currentDimensions['height']; $reflectionHeight = intval($height * ($reflection / 100)); $newHeight = $height + $reflectionHeight; $reflectedPart = $height * ($percent / 100); $this->workingImage = ImageCreateTrueColor($width,$newHeight); ImageAlphaBlending($this->workingImage,true); $colorToPaint = ImageColorAllocateAlpha($this->workingImage,255,255,255,0); ImageFilledRectangle($this->workingImage,0,0,$width,$newHeight,$colorToPaint); imagecopyresampled( $this->workingImage, $this->newImage, 0, 0, 0, $reflectedPart, $width, $reflectionHeight, $width, ($height - $reflectedPart)); $this->imageFlipVertical(); imagecopy($this->workingImage,$this->newImage,0,0,0,0,$width,$height); imagealphablending($this->workingImage,true); for($i=0;$i<$reflectionHeight;$i++) { $colorToPaint = imagecolorallocatealpha($this->workingImage,255,255,255,($i/$reflectionHeight*-1+1)*$white); imagefilledrectangle($this->workingImage,0,$height+$i,$width,$height+$i,$colorToPaint); } if($border == true) { $rgb = $this->hex2rgb($borderColor,false); $colorToPaint = imagecolorallocate($this->workingImage,$rgb[0],$rgb[1],$rgb[2]); imageline($this->workingImage,0,0,$width,0,$colorToPaint); //top line imageline($this->workingImage,0,$height,$width,$height,$colorToPaint); //bottom line imageline($this->workingImage,0,0,0,$height,$colorToPaint); //left line imageline($this->workingImage,$width-1,0,$width-1,$height,$colorToPaint); //right line } $this->oldImage = $this->workingImage; $this->newImage = $this->workingImage; $this->currentDimensions['width'] = $width; $this->currentDimensions['height'] = $newHeight; } /** * Inverts working image, used by reflection function * */ private function imageFlipVertical() { $x_i = imagesx($this->workingImage); $y_i = imagesy($this->workingImage); for($x = 0; $x < $x_i; $x++) { for($y = 0; $y < $y_i; $y++) { imagecopy($this->workingImage,$this->workingImage,$x,$y_i - $y - 1, $x, $y, 1, 1); } } } /** * Converts hexidecimal color value to rgb values and returns as array/string * * @param string $hex * @param bool $asString * @return array|string */ private function hex2rgb($hex, $asString = false) { // strip off any leading # if (0 === strpos($hex, '#')) { $hex = substr($hex, 1); } else if (0 === strpos($hex, '&H')) { $hex = substr($hex, 2); } // break into hex 3-tuple $cutpoint = ceil(strlen($hex) / 2)-1; $rgb = explode(':', wordwrap($hex, $cutpoint, ':', $cutpoint), 3); // convert each tuple to decimal $rgb[0] = (isset($rgb[0]) ? hexdec($rgb[0]) : 0); $rgb[1] = (isset($rgb[1]) ? hexdec($rgb[1]) : 0); $rgb[2] = (isset($rgb[2]) ? hexdec($rgb[2]) : 0); return ($asString ? "{$rgb[0]} {$rgb[1]} {$rgb[2]}" : $rgb); } /** * Reads selected exif meta data from jpg images and populates $this->imageMeta with appropriate values if found * */ private function gatherImageMeta() { //only attempt to retrieve info if exif exists if(function_exists("exif_read_data") && $this->format == 'JPG') { $imageData = exif_read_data($this->fileName); if(isset($imageData['Make'])) $this->imageMeta['make'] = ucwords(strtolower($imageData['Make'])); if(isset($imageData['Model'])) $this->imageMeta['model'] = $imageData['Model']; if(isset($imageData['COMPUTED']['ApertureFNumber'])) { $this->imageMeta['aperture'] = $imageData['COMPUTED']['ApertureFNumber']; $this->imageMeta['aperture'] = str_replace('/','',$this->imageMeta['aperture']); } if(isset($imageData['ExposureTime'])) { $exposure = explode('/',$imageData['ExposureTime']); $exposure = round($exposure[1]/$exposure[0],-1); $this->imageMeta['exposure'] = '1/' . $exposure . ' second'; } if(isset($imageData['Flash'])) { if($imageData['Flash'] > 0) { $this->imageMeta['flash'] = 'Yes'; } else { $this->imageMeta['flash'] = 'No'; } } if(isset($imageData['FocalLength'])) { $focus = explode('/',$imageData['FocalLength']); $this->imageMeta['focalLength'] = round($focus[0]/$focus[1],2) . ' mm'; } if(isset($imageData['DateTime'])) { $date = $imageData['DateTime']; $date = explode(' ',$date); $date = str_replace(':','-',$date[0]) . ' ' . $date[1]; $this->imageMeta['dateTaken'] = date('m/d/Y g:i A',strtotime($date)); } } } /** * Rotates image either 90 degrees clockwise or counter-clockwise * * @param string $direction */ public function rotateImage($direction = 'CW') { if($direction == 'CW') { $this->workingImage = imagerotate($this->workingImage,-90,0); } else { $this->workingImage = imagerotate($this->workingImage,90,0); } $newWidth = $this->currentDimensions['height']; $newHeight = $this->currentDimensions['width']; $this->oldImage = $this->workingImage; $this->newImage = $this->workingImage; $this->currentDimensions['width'] = $newWidth; $this->currentDimensions['height'] = $newHeight; } public function watermark($imagesource){ $pathinfo = pathinfo($imagesource); $var1 = $pathinfo['extension']; $var2 = "png"; $var3 = "jpeg"; $var4 = "jpg"; $var5 = "gif"; if(strcasecmp($var1, $var2) == 0){ $watermark = @imagecreatefrompng($imagesource); }elseif((strcasecmp($var1, $var3) == 0) || (strcasecmp($var1, $var4) == 0)){ $watermark = @imagecreatefromjpeg($imagesource); }elseif(strcasecmp($var1, $var5) == 0){ $watermark = @imagecreatefromgif($imagesource); } $watermarkwidth = imagesx($watermark); $watermarkheight = imagesy($watermark); $startwidth = ($this->currentDimensions['width'] - $watermarkwidth); $startheight = ($this->currentDimensions['height'] - $watermarkheight); imagecopy($this->workingImage, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight); } } I made this function to work in the class. But it wont work. So can you guys help me? public function resizeThumbnailImage($width, $height, $start_width, $start_height, $scale){ $newImageWidth = ceil($this->currentDimensions['width'] * $scale); $newImageHeight = ceil($this->currentDimensions['height'] * $scale); if(function_exists("ImageCreateTrueColor")) { $this->workingImage = ImageCreateTrueColor($newImageWidth,$newImageHeight); } else { $this->workingImage = ImageCreate($newImageWidth,$newImageHeight); } imagecopyresampled($this->workingImage,$this->oldImage,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$newImageWidth,$height); //$this->oldImage = $this->workingImage; //$this->newImage = $this->workingImage; //$this->currentDimensions['width'] = $width; //$this->currentDimensions['height'] = $height; }
  10. Hey guys, Here is what I am doing. I am storing images on Amazon S3 cloud and Mosso cloud systems. What I want to do is ping Amazon S3 cloud first to make sure it's online and if it's not I ping the second one that being Mosso cloud system to see if it's online. The mosso cloud is like a back up in a way. So here is my function code. Tell me if there is a better way on doing this... // constants.php file define("AMAZON_IMAGES", "s3.amazonaws.com"); define("MOSSO_IMAGES", "cdn.cloudfiles.mosso.com"); // function.php file function images_ping3rdparties($amazonURL, $mossoURL){ // Going to check if Amazon is working first, if it's not we switch the user over to Mosso. // If Mosso down we give the user an error. // Amazon = 2, Mosso = 1, Error = 0 $amazon = @fsockopen("$amazonURL", 80, $errno, $errstr, 2); $mosso = @fsockopen("$mossoURL", 80, $errno, $errstr, 2); if(!$amazon) { if(!$mosso) { $status = '0'; } else { $status = '1'; fclose($mosso); //fclose($amazon); } } else { $status = '2'; fclose($mosso); fclose($amazon); } return $status; }
  11. I wanted to share this. ( http://www.gen-x-design.com/projects/php-thumbnailer-class/ ) I think it's the best script ever when it comes to handling images. You can corp, resize, make thumbs, and more... Oh you might wanna use this if your system locks up on you. This if you are handling large files like I am... <?php ini_set('memory_limit','40M'); ?> Oh and if you know a better one let me know!!!
  12. Thanks methodlessman.... I totally forgot about that code. Thanks!
  13. Hey programmers, I wanna pull a code apart. Here is the example. 123-765432-436436 I want to pull them apart and be like this $number = '123'; // So basically pull the first set of code before the - $number2 = '765432'; // So basically pull the second set of code after the first - $number3 = '436436'; // So basically pull the third set of code after the second - I need to do this to supply to the database. Thank you!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.