During program development, users often encounter the need to upload images to generate small thumbnails. Because the length and width ratios of the images uploaded by users are different, it is a problem to display the small images neatly on the page when they are generated proportionally.
Considering that proportional scaling is required for images, it is better to add the edge whitelist when displaying images. As follows:
Figure 1 dimension 480x350
Figure 2 dimension 270x360
If we set the si
Giant Curtain:Divclass= "Jumbotron"> Divclass= "Container"> H1>W3schoolH1> P>Study hard and learn to learn day in and day out good study dayP> P>ahref="#"class= "Btn btn-primary">Are you surea>P> Div>Div>Figure:Thumbnail Image:thumbnail thumbnail image -Divclass= "Container"> Divclass= "Row"> Divclass= "Col-lg-2"> ahref= "Www.baidu.com"class= "thumbnail">
Copy CodeThe code is as follows:
/*
* @im//Picture resources that need to be scaled
* @filetype//production of thumbnail file type
* @dstimW//Zoom the width of the picture
* @dstimH//height of the picture to zoom
* @thumbname//thumbnail file name
function Makethumb ($im, $dstimW, $dstimH, $thumbname, $filetype) {
Get the width and height of IM
$pic _w=imagesx ($im);
$pic _h=imagesy ($im);
$arr = Array ();
allowed
$overwrite = 0;
Initialize the Upload class
$f = new Clsupload ($savePath, $fileFormat, $maxSize, $overwrite);
If you want to generate thumbnails, call the member function $f->setthumb ();
Parameter list: Setthumb ($thumb, $thumbWidth = 0, $thumbHeight = 0)
$thumb =1 indicates that a thumbnail is to be generated, and when not called, its value is 0
$thumbWidth thumbnail width, in pixels (px), left
This is a small demand from a customer. The image upload function displays thumbnails on the display page, move the mouse over the display source image, and click the thumbnail to open a new page to display the source image. This is probably the case.
Directly paste code
Backend. CS
// It is used to solve the updatepale problem. After refreshing, The updatepale effect is lost.
Protected void page_load (Object sender, eventargs E){This. registersta
/**
* Upload Images
*/
Class imgupload{
static protected $a;
protected $formName; Form name
protected $directory; File Upload to Directory
protected $maxSize; Maximum file Upload size
protected $canUpload; Whether you can upload
protected $doUpFile; File name of the upload
protected $SM _file; Thumbnail name
Private function __construct ($_formname= ' file ', $_directory= './images/uploads/'
Phpcmsv9 intends to call the thumbnail as a big image of the magic lamp, but the thumbnail is blurred according to the online method {code ...} I tried it in various ways, but it still does not take effect. phpcms v9 intends to call the thumbnail as a magic lamp, but the thumbnail is very fuzzy.
According to the met
Recently with Phpcms V9 again encountered an old problem: in the content page thumbnail clipping when the black edge, this situation has not met, is estimated to be long or wide different or will be in the Home page, list page, content pages in different places accidentally appear, here cmsyou share under Phpcms V9 thumbnail Clipping There is a workaround for black edges.In the phpcms V9
Microsoft adds a variety of effects and features to the Win7 64-bit flagship operating system, previewing thumbnails is also a cool, practical feature that allows us to quickly find pictures by previewing thumbnails, but recently a user has been reflected in a slow response when opening a preview thumbnail in a win7 system. This problem occurs we can modify the system settings to elevate the preview thumbnail
First, the problem scene
Generates a 48pxx48px thumbnail for a square picture and saves it as a picture file, but finds that the resulting thumbnail is blurry.
The resulting blur thumbnail is as follows:
Original picture (300pxx300px, PNG format):
System.Drawing.Image is called in the code. Getthumbnailimage () method, the main implementation code is as f
/// /// Image thumbnail Processing/// /// /// /// /// Publicstaticvoid createthumbnailpicture (string srcpath, string destpath, int width, int height){// Obtain the image object of the source image based on the absolute path of the image DiskSystem. Drawing. Image IMG = system. Drawing. image. fromfile (srcpath );
// BMP: the thumbnail bitmap object to be created.Bitmap BMP = new Bitmap (width, height );
I. Technical Overview:1. Ajax does not need to upload images. For more information, see my article (jquery + C # ashx)2. C # Bitmap Processing System. Drawing.3. The latest demo supports IE7, IE8, and Firefox.Ii. How to Deal with thumbnail:Core Method for generating a thumbnail:Createthumbnailpicture////// Image thumbnail Processing///////////////Public static void createthumbnailpicture (string srcpath, string destpath, int width, int height){// Obta
the partition is 400, the height is 300, and then the picture from the coordinates (0,0) from the projection to the picture $image_p, the width of the projection is $new_width, the height is $new_ Height
File and Zoom dimensions$imgfile = ' smp.jpg ';$percent = 0.2;Header (' Content-type:image/jpeg ');List ($width, $height) = getimagesize ($imgfile);$newwidth = $width * $percent;$newheight = $height * $percent;$thumb = Imagecreatetruecolor ($newwidth, $newheight);$source = Imagecreat
A total of two equal proportional thumbnail methods can be used for reference
One, for the class file, after instantiation can be used
Second, for the custom method, relatively lightweight
class fileCopy CodeThe code is as follows: $resizeimage = new Resizeimage ("./shawn.jpg", "200", "100", "0", "... /pic/shawnsun.jpg ");Instantiate the following class to generate a thumbnail imageWhere the source file an
. This example has an. htaccess file with file upload size and post size and then Inline code for dynamic system memory.
Htaccess file:Php_value post_max_size 16 mPhp_value upload_max_filesize 6 m
// $ Img_base = base directory structure for thumbnail images// $ W_dst = maximum width of thumbnail// $ H_dst = maximum height of thumbnail// $ N_img = new
In. NET development, you need to get the height and width of the image. The Code is as follows:Protected string imgpath;
Protected string fileextname;
Private void btnget_click (Object sender, system. eventargs E)
...{
If (upimage. postedfile. filename! = "")
...{
Imgpath = upimage. postedfile. filename;
Fileextname = imgpath. substring (imgpath. lastindexof (".") + 1, 3 );
If (fileextname! = "GIF" fileextname! = "Jpg ")
...{
Response. Write ("Select images in GIF and jpg Formats ");
}
Else
.
);
}
/*************************************** *********
// Function: thumbnail ($ srcimg, $ multiple)
// Function: generate a thumbnail
// Parameters:
// $ Srcimg is required. Source image file name
// $ Multiple is optional. The scaling factor. The default value is 2 times, which is reduced to 1/2 of the original one.
// Note: Only images in gif, jpg, and png formats are supported.
// Example:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.