`
天梯梦
  • 浏览: 13756865 次
  • 性别: Icon_minigender_2
  • 来自: 洛杉矶
社区版块
存档分类
最新评论

php 截图(可预览) crop images thumb jcrop/asido

 
阅读更多

jcrop + asido 

 

index.php

 

 

<?php
$targ_w = 90; // thumb width size
$targ_h = 89; // thumb height size

$filename = $_GET['file'];
if($filename)
{
    $abs = '/home/www';
    
    $fullsrc = '/public/images/'.$filename; // absolute path of original image uploaded
    $thumbsrc = '/public/images/thumb-'.$filename; // absolute path of thumb image you want 

    $fullroot = $abs.$fullsrc;
    $thumbroot = $abs.$thumbsrc;
    
    if ($_SERVER['REQUEST_METHOD'] == 'POST') 
    {
        include('asido/class.asido.php');
        asido::driver('gd');
        $i1 = asido::image($fullroot, $thumbroot);
        Asido::Crop($i1, $_POST['x'], $_POST['y'], $_POST['w'], $_POST['h']);
        $i1->save(ASIDO_OVERWRITE_ENABLED);

        // if you want to make resize via scale automatically, or you can remove it
        $i1 = asido::image($thumbroot, $thumbroot);
        Asido::resize($i1, $targ_w, $targ_h, ASIDO_RESIZE_STRETCH);
        $i1->save(ASIDO_OVERWRITE_ENABLED);
        
        exit('<img src="'.$thumbsrc.'" /><br><a href="?file='.$filename.'&sv='.time().'">Create Thumbnail Again</a>');
    }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Add a New WithStars</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="GLS PHP Framework">
<meta name="author" content="GLS">
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="expires" content="Thu, 01 Jan 1970 00:00:01 GMT" />
<meta http-equiv="expires" content="0" />
<script type="text/javascript" src="js/jquery.js"></script>
<script language="JavaScript" type="text/javascript" src="js/jcrop.js"></script>
<script>
jQuery(function($){
	// Create variables (in this scope) to hold the API and image size
	var jcrop_api, boundx, boundy;
  
	$('#cropbox').Jcrop({
		onChange: updatePreview,
		onSelect: updatePreview,
		aspectRatio: 1
	},function(){
		// Use the API to get the real image size
		var bounds = this.getBounds();
		boundx = bounds[0];
		boundy = bounds[1];
		// Store the API in the jcrop_api variable
		jcrop_api = this;
	});

	function updatePreview(c)
	{
		if (parseInt(c.w) > 0)
		{
			$('#x').val(c.x);
			$('#y').val(c.y);

			var rx = <?=$targ_w?> / c.w;
			var ry = <?=$targ_h?> / c.h;

			$('#w').val(c.w);
			$('#h').val(c.h);

			// if you don't want to preview, you can remove it
			$('#preview').css({
				width: Math.round(rx * boundx) + 'px',
				height: Math.round(ry * boundy) + 'px',
				marginLeft: '-' + Math.round(rx * c.x) + 'px',
				marginTop: '-' + Math.round(ry * c.y) + 'px'
			});
		}
	};

	function checkCoords()
	{
		if (parseInt($('#w').val())) return true;
		alert('Please select a crop region then press submit.');
		return false;
	};
});
</script>
<link href="css/jcrop.css" rel="stylesheet" type="text/css" />
<body>
    <form method="post" onsubmit="return checkCoords();">
        <table>
            <tr>
                <td><img src="<?=$fullsrc?>" id="cropbox" /></td>
                <td>
                    <h4>Preview pane:</h4>
                    <div style="overflow: hidden; width: <?=$targ_w?>px; height: <?=$targ_h?>px;border:#ccc 1px solid;padding:3px;"><img id="preview" src="<?=$fullsrc?>"/></div>
                    <div style="margin:5px;"><input type="submit" name="crop" value="Crop Image" /></div>
                </td>
            </tr>
        </table>
        <div style="margin:5px;">
			<input type="hidden" id="x" name="x" />
			<input type="hidden" id="y" name="y" />
			<input type="hidden" id="w" name="w" />
			<input type="hidden" id="h" name="h" />
        </div>
    </form>
</body>
</html>
<?php }?>
 

jcrop.css

 

 

.jcrop-holder { text-align: left; }

.jcrop-vline, .jcrop-hline
{
	font-size: 0;
	position: absolute;
	background: white url('jcrop.gif') top left repeat;
}
.jcrop-vline { height: 100%; width: 1px !important; }
.jcrop-hline { width: 100%; height: 1px !important; }
.jcrop-handle {
	font-size: 1px;
	width: 7px !important;
	height: 7px !important;
	border: 1px #eee solid;
	background-color: #333;
	*width: 9px;
	*height: 9px;
}

.jcrop-tracker { width: 100%; height: 100%; }

.custom .jcrop-vline,
.custom .jcrop-hline
{
	background: yellow;
}
.custom .jcrop-handle
{
	border-color: black;
	background-color: #C7BB00;
	-moz-border-radius: 3px;
	-webkit-border-radius: 3px;
}
 

 

 

参考来源:

http://asido.info/

http://asido.info/about/features/

http://sourceforge.net/projects/asido/

 

http://deepliquid.com/content/Jcrop.html

http://code.google.com/p/jcrop/

 

转帖注明:justcoding http://justcoding.iteye.com/blog/1430913

 

 

 

 

  • 大小: 329 Bytes
分享到:
评论
1 楼 phperbar 2012-07-11  
不错,学习了

相关推荐

    jCrop jquery 裁剪图片 加 上传 php代码

    `jCrop` 是一个基于 jQuery 的强大图片裁剪插件,它允许用户在浏览器端选择并裁剪图像,然后将这些裁剪信息发送到服务器进行进一步处理。在这个项目中,`jCrop` 被用来配合 PHP 完成图片的上传和剪切功能。 1. **...

    PHP+jQuery+jCrop裁剪头像

    在本项目中,“PHP+jQuery+jCrop裁剪头像”是一个常见的在线图像处理应用场景,用于让用户自定义上传的头像尺寸,以满足特定的显示需求。以下是对该项目中涉及的关键技术点的详细解释: 1. **PHP**:PHP(Hypertext...

    jQuery Jcrop 实现图像裁剪Demo

    jQuery Jcrop是一款强大的JavaScript库,专门用于在网页上实现图像的选择和裁剪功能。它结合了jQuery的简洁API和强大的图像处理能力,为开发者提供了一种简单易用的方式来实现图像裁剪,尤其适用于用户需要自定义...

    Jcrop 小测试源码

    在实际应用中,Jcrop 可以广泛用于各种场景,例如在线头像裁剪、图片编辑工具、预览裁剪结果等。通过这个小测试源码,开发者可以快速理解 Jcrop 的基本用法,包括如何绑定图像、如何设置裁剪选项、如何监听和处理...

    carrierwave-crop:使用带有预览功能的Jcrop插件进行载波扩展以裁剪上传的图像

    载波裁剪 CarrierWave扩展程序可使用带有预览功能的Jcrop插件裁剪上传的图像。安装安装最新的稳定版本: $[sudo] gem install carrierwave-crop在Rails中,将其添加到您的Gemfile中: gem 'carrierwave-crop'然后...

    papercrop:Paperclip的一个简单扩展,可以使用jCrop裁剪图像上传

    裁剪纸 Paperclip的一个简单扩展,可以使用jCrop裁剪上载的图像。... has_attached_file :avatar, :styles =&gt; {:thumb =&gt; '50x50', :medium =&gt; '100x100'} crop_attached_file :avatar 默认情况下,

    spring mvc thumbnailator +jcrop 实现头像裁剪

    Jcrop与后端配合,可以实时预览裁剪效果,并将裁剪参数(如坐标和比例)发送到服务器。Jcrop通过CSS和JavaScript实现,兼容各种浏览器,提供良好的用户体验。在HTML页面中,你需要引入Jcrop的CSS和JS文件,然后绑定...

    PHP实例开发源码—PHP+ajaxfileupload+jcrop插件完美实现头像上传剪裁.zip

    在本实例中,我们主要探讨如何使用PHP与前端技术AJAX、FileUpload和Jcrop插件相结合,实现一个完整的头像上传及剪裁功能。这个功能常见于许多社交媒体和个人资料编辑页面,允许用户自主选择并调整上传的头像图片。 ...

    使用Python-OpenCV对多张图片进行全景图像拼接消除鬼影消除裂缝源码.zip

    python image_stitching.py --images images/scottsdale --output output.png --crop 1 其中images/scottsdale为待拼接图像所在文件夹,output.png为处理拼接保存后的图像;这里使用了相对路径,因为在工程根目录下...

    jcrop上传、裁剪头像

    在IT行业中,头像上传和裁剪功能是许多网站和应用程序不可或缺的一部分,它涉及到前端交互、图像处理和后端存储等多个环节。本项目以“jcrop上传、裁剪头像”为主题,通过使用jCrop这一JavaScript图像裁剪库,实现了...

    Python实现对多张图片进行全景图像拼接,消除鬼影,消除裂缝

    使用方式python image_stitching.py --images images/scottsdale --output output.png --crop 1其中images/scottsdale为待拼接图像所在文件夹,output.png为处理拼接保存后的图像;这里使用了相对路径,因为在工程根...

    crop-loader:用于裁剪图像的 Webpack 加载器

    crop!../assets/sprite.png?x=0&y=0&w=144&h=256' ) , ground : require ( 'file!crop!../assets/sprite.png?x=146&y=0&w=154&h=56' ) , score : require ( 'file!crop!../assets/sprite.png?x=146&y=58&w=113&h=...

    基于Python+OpenCV对多张图片进行全景图像拼接源码+项目使用说明(课程设计大作业).zip

    python image_stitching.py --images images/scottsdale --output output.png --crop 1 其中images/scottsdale为待拼接图像所在文件夹,output.png为处理拼接保存后的图像;这里使用了相对路径,因为在工程根目录下...

    基于Python+OpenCV的对多张图片进行全景图像拼接项目源码(95分以上大作业).zip

    【使用方法】python image_stitching.py --images images/scottsdale --output output.png --crop 1其中images/scottsdale为待拼接图像所在文件夹,output.png为处理拼接保存后的图像;这里使用了相对路径,因为在...

    PHP结合JQueryJcrop实现图片裁切实例详解

    PHP结合JQueryJcrop实现图片裁切是一项常见但功能强大的Web开发技术,它允许用户通过简单的用户界面来选择图片的某个区域并进行裁剪。本知识点将详细介绍如何通过PHP与JQueryJcrop插件结合使用来实现图片裁切功能。 ...

    struts2加jquery加Jcrop实现头像剪切上传项目版(添加jar包部署就可以运行)

    Struts2、jQuery和JCrop是开发Web应用中常见的技术栈,它们被广泛用于构建交互式的用户界面,尤其是处理图像操作。在这个项目中,我们主要关注如何利用这些技术实现一个头像剪切并上传的功能。 首先,Struts2是一个...

    h5Crop:一个基于jQuery和Jcrop的本地图片裁剪插件

    一个基于和的本地图片裁剪插件。 ####License: ###为什么需要这玩意 目前很多的图片上传、裁剪都是基于服务器端的。比如Jcrop,在选择好图片后仅仅是做了一个裁剪的UI,然后... previewW: 400, // 预览宽度(高度自

    Vue3+TS图片裁切组件

    import ImageCrop from "@/components/image-crop/" const app = createApp(App) app.use(ImageCrop); app.mount('#app ') 在对应的页面使用 &lt;ImageCrop :aspectRatio="裁切比例,不用此参数自由裁切" :src="原图...

    GBS-SNP-CROP:GBS SNP呼叫参考可选管道

    GBS-SNP-CROP最新版本v.4.1(2019年10月6日)介绍在GBS SNPÇ阿灵- [R eferenceöptional P ipeline(GBS-SNP-CROP)经由的顺序的顺序执行集成了定制解析和过滤用公知的,核实生物信息学工具程序,给用户完全访问...

Global site tag (gtag.js) - Google Analytics