问题标签 [getimagesize]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
php - PHP - 获取 blob 图像大小 - FPDF - getimagesizefromstring 不起作用
所以我使用 php/oracle 通过 FPDF 类/插件创建 PDF。我正在使用 Mem_Image 类/脚本将 blob 图像添加到我的 PDF,但我无法确定图像的大小。我正在运行 PHP 5.2,所以 getimagesizefromstring 不起作用。
对于图像,它将具有我可以在 FPDF 类中设置的固定高度,但由于它可能是纵向或横向图像,因此我需要按比例缩放图像。
ajax - jQuery Masonry 和 Ajax-fetching 追加项目导致图像重叠
此处使用 Masonry 和 Ajax 在 Wordpress 中附加项目的另一个图像重叠问题。第一次添加更多项目时,图像会重叠。但是,当页面重新加载时,图像不再重叠。在做了一些研究后,我意识到这与计算图像的高度有关。
在 Masonry 网站的帮助页面中,建议使用getimagesize函数来指定图像的宽度和高度。
但是,这就是我卡住的地方。由于我对 PHP 的了解有限,我不知道如何使用这个函数或将它放在我的代码中的什么位置,所以我在这里寻找一点方向。谁能帮我弄清楚如何将getimagesize函数集成到我的代码中?
这是砌体代码:
这是ajax获取代码:
php - getimagesize() 限制远程 URL 的文件大小
我可以getimagesize()
用来验证图像,但问题是如果淘气的用户放置一个10GB 随机文件的链接,那么它会破坏我的生产服务器的带宽。如何限制文件大小getimagesize()
?(例如,最大图像大小为 5MB)
PS:我在问之前做了研究。
android - Android:API 中的 bitmap.getByteCount() 小于 12
当我在将图像保存到 SD 卡之前搜索如何找到图像的大小时,我发现了这个:
但是该方法是在 API 12 中添加的,我正在使用 API 10。所以我再次发现了这一点:
getByteCount() 只是一种方便的方法,它完全按照您在 else 块中放置的操作。换句话说,如果你简单地重写 getSizeInBytes 以始终返回“bitmap.getRowBytes() * bitmap.getHeight()”
这里:
所以,通过计算这个bitmap.getRowBytes() * bitmap.getHeight()
我得到了价值120000 (117 KB)
。
其中 SD 卡上的图像大小为1.6 KB
.
我错过了什么?还是做错了?
谢谢你
php - 通过PHP上传图片的防弹方法
在过去的几周里,我一直在研究这个话题,我真的开始烦恼我找不到明确的答案。
我有一个网站,用户可以在其中上传自己的个人资料图片。我想确保允许上传的唯一文件是 JPEG、GIF 和 PNG
显然,使用浏览器发送的 mime 类型进行验证是一个很大的禁忌,因为它很容易被欺骗,因此排除了这种情况,而且不用说永远不要验证文件扩展名。
接下来是 PHP 提供的新的(ish)finfo 函数。我暂时一直在使用它,因为它似乎是最好的可用方法,但阅读http://www.php.net/manual/en/ref.fileinfo.php上的评论似乎也可以被欺骗。此外,我不确定仅检查返回的 MIME 类型是否为 image/jpeg、image/gif 或 image/png 是否过于严格?
然后是 getimagesize() 函数,我读到的任何不是看起来完美的图像的东西都返回 false,但如果是这种情况,为什么这里有这么多公认的答案说使用 finfo?
最后是 system() 或 exec() 调用,允许用户指定系统调用的一部分似乎有点危险!
所以我的问题是,我应该使用什么方法?我想让我的脚本尽可能安全,但也要足够开放,这样普通用户就不会因为他们的有效图像被脚本拒绝而受到惩罚
php - PDF的PHP getimagesize - > Blob
我正在尝试实现将 PDF 上传添加到我继承的现有图像上传功能的能力。我注意到我无法在 PDF 上使用 getimagesize。有没有办法使用 PHP 确定 PDF 的尺寸?- 或者 - 在上传 PDF 时对尺寸进行硬编码会更好吗?
jquery - 在谷歌浏览器中获取图像大小未定义
我的 html 中有几个图像标签和 div,如下所示。
我的要求是计算每个图像的高度 * 宽度,如果高度 * 宽度 <5000,则执行以下操作。1)删除相应的div 2)删除相应图像的“captify”类
为此,我尝试了以下脚本来处理 google chrome,因为我已经设法使用其他方法为 IE 和 firefox 工作。
任何人都可以帮我解决这个问题。提前谢谢了
php - 动态图像上的getimagesize
我有一个 MySQL 表,我在其中将用户头像存储为 blob。我使用名为 avatar.php 的脚本获取这些图像,该脚本输出图像。要请求特定的用户图像,您必须调用 avatar.php?id=(user id)。为了使动态图像名称更漂亮,我在 .htaccess 中添加了 URL 重写,因此您也可以调用 avatar-(userid).jpg,它将转换为 avatar.php?id=(userid)。
现在我想获取用户图像并使用 GD 对其进行操作。我尝试使用 getimagesize() 和 imagecreatefromjpeg() 但我不断收到“无法打开流,没有这样的文件或目录”错误。我尝试使用这些函数的两个脚本,如 avatar.php 脚本,位于根目录中。我试过了:
当我使用我网站的完整网址(包括 http:// 等)时,它实际上可以工作......但我还没有找到原因。
//编辑:使用 file_exists() 函数时会出现类似的问题。如果我尝试 file_exists('./avatar.php') 它返回 true,如果我添加 get-vars 它返回 false。这些功能不适合动态文件吗?
有人可以帮帮我吗?
提前致谢
php - PHP getimagesize, Mysql fetch from DB and update field
I've been a lot around this site the last couple of days, and found a lot of useful tips for a newbie to php as I am (this is my second day :) ) Therefore I'll sure hope you gurus can help me finishing this script.
What do I have: I have this table within my Mysql:
Would should it do:
The script have to get some table rows where the "diemensions" field is emty IS NULL
Now the script have to find the image size and spit it out in this format widthxheight the x between the width and height is important.
Where the image is not to be grabt, it should just pass by, and take the next one.
When it's done: It have grabt the image size and updated the "dimensions" field in the DB
Sources for my code: How to determine the picture size, then selectively insert into the database? php
Update MySql Field (if field is not empty, go to next one)
http://dk1.php.net/manual/en/function.getimagesize.php
The PHP it self
Seen but couldn't make it work http://dk1.php.net/manual/en/function.getimagesize.php Post by "james dot relyea at zifiniti dot com 07-Feb-2009 08:49" But seems to be the right ideer for my script.
XXXXXXXXXXXXXXXXX When you answer this topic, please explane wich part does what.
Best Regards
Joakim
php - 不同的“jpeg”扩展和 php 的 getimagesize()
所以, some img 有.jpg
扩展名, some .jpeg
, some.JPG
和 some .JPEG
。
问题:对于 php 函数getimagesize()
,这 4 个扩展是相同的,并且总是返回image/jpeg
为 mime 类型?