PHPackages                             lipowei/img - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. lipowei/img

Abandoned → [tcwei/imgsrc](/?search=tcwei%2Fimgsrc)Library[Image &amp; Media](/categories/media)

lipowei/img
===========

高效率字符串模式（可比正则获取快3倍）从HTML或者文章内容等字符串中提取图片的src，可指定提取第几张图片、顺数第几或逆数第几、可指定黑名单等。页面下面有使用例子：

v2.02(4y ago)3114511[1 PRs](https://github.com/ITzhiwei/getImgSrc/pulls)MITPHP

Since Jul 5Pushed 4y ago3 watchersCompare

[ Source](https://github.com/ITzhiwei/getImgSrc)[ Packagist](https://packagist.org/packages/lipowei/img)[ RSS](/packages/lipowei-img/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (4)Used By (0)

安装
==

[](#安装)

composer安装： composer require tcwei/imgsrc

GetImgSrc::src 单张获取(可比普通正则获取快3倍)
================================

[](#getimgsrcsrc-单张获取可比普通正则获取快3倍)

获取HTML字符串中的图片地址 用法示例：

use tcwei\\smallTools\\GetImgSrc;
$htmlStr = '这里可以是新闻等文章或者html内容';
//获取首张图片的src
$imgSrc = GetImgSrc::src($htmlStr, 1);

```
/**
 * 提取HTML文章中的图片地址
 * @param string $data
 * @param int $num 第 $num 个图片的src，默认为第一张
 * @param string $order 顺取倒取； 默认为 asc ，从正方向计数。 desc 从反方向计数
 * @param string|array $blacklist 图片地址黑名单，排除图片地址中包含该数据的地址；例如 传入 baidu.com  会排除 src="http://www.baidu.com/img/a.png"
 * @param string $model 默认为字符串模式;可取值 string  preg；string模式处理效率高，PHP版本越高速度越快，可比正则快几倍
 * @return false | null | src  当data为空时返回 false ， src不存在时返回 null ，反之返回src
 */
public static function src($data = null, $num = 1, $order = 'asc', $blacklist = false, $model = 'string'){...

```

GetImgSrc::srcList 多张获取
=======================

[](#getimgsrcsrclist-多张获取)

//从第一张获取，共获取3张
$srcArr = GetImgSrc::srcList($htmlStr, 1, 3);
参数解释：

```
/**
  * 提取HTML文章中的图片地址
  * @param string $data HTML或者文章
  * @param int $startNum 默认为1，从第一张图片开始抽取
  * @param int $length 从 $startNum 开始抽取，共抽取 $length 张；默认为0，为0则抽取到最后
  * @param string $order 顺取倒取； 默认为 asc ，从正方向计数。 desc 从反方向计数
  * @param string|array $blacklist 图片地址黑名单，排除图片地址中包含该数据的地址；例如 传入 img.baidu.com  会排除 src="img.baidu.com/a.png"
  * @param string $model 抽取集合时，默认为正则模式；可选模式：preg  string，当 $length > 3 或者 $length = 0时，强制使用正则模式，因为取的数量大时，正则速度更快。
  * @return 图片地址的集合数组，若无则返回空数组[]
  */
public static function srcList($data, $startNum = 1, $length = 0, $order = 'asc', $blacklist = false, $model = 'preg'){

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~173 days

Total

3

Last Release

1794d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/64b02e6dd1c2046465a92a43050180747375fed27151c08abc2a336d83968d92?d=identicon)[ITwuzhiwei](/maintainers/ITwuzhiwei)

---

Top Contributors

[![ITzhiwei](https://avatars.githubusercontent.com/u/31977386?v=4)](https://github.com/ITzhiwei "ITzhiwei (9 commits)")[![aodizhang](https://avatars.githubusercontent.com/u/18239496?v=4)](https://github.com/aodizhang "aodizhang (1 commits)")

### Embed Badge

![Health badge](/badges/lipowei-img/health.svg)

```
[![Health](https://phpackages.com/badges/lipowei-img/health.svg)](https://phpackages.com/packages/lipowei-img)
```

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
