定制 antey/instagram-image 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

antey/instagram-image

Composer 安装命令:

composer require antey/instagram-image

包简介

Library for resizing images according to instagram requirements

README 文档

README

PHP library designed for easy image formatting for Instagram according to Instagram guidelines.

tests workflow Coverage Status License: MIT

Setup

Via composer:

$ composer require antey/instagram-image

Or by cloning repository

Requirements

  • PHP version: >= 7.4;
  • PHP extensions: gd.

Dependencies

Usage

This package allow to resize image to any resolution, according to instagram requirements or get optimal resolution for post or gallery (description of features is below).

Instagram resolutions

  • Profile photo - 360x360 px;
  • Stories - 1080x1920 px;
  • Reels - 1080x1920 px;
  • IGTV cover - 420x654 px;
  • Square post - 1080x1080 px;
  • Landscape post - 1080x564 px;
  • Portrait post - 1080x1350 px;

Resizing

Package allow to simple resize original image into one of instagram images, using one of methods: getProfile, getIgtvCover, getSinglePostSquare, getSinglePostLandscape and getSinglePostPortrait.

Slicing

Different to simple resizing, instagram also allow to publish some multiple images. It can be Stories, Reels, Post with several images. To create this types of images, package provide methods, that resize and slice original image into a pieces. List of this methods: getStories, getReels, getGallerySquare, getGalleryLandscape, getGalleryPortrait.

Optimal resizing

To simplify work with Post, package provide methods, that will automatically find most reliable type (single image or gallery) and resolution (Square, Landscape, Portrait) for given image and return path to resized image, or paths of sliced pieces. It's getSinglePostOptimal, getGalleryOptimal, getPostOptimal.

Available features

Resizing initialization

use Antey\InstagramImage\InstagramImageResize;

$imageResize = new InstagramImageResize();

Resizing simple images

For simple images (like a Profile, Stories, Reels, IGTVCover) resized image (or images gallery) will be created by single specified method.

getProfile

$imageResize->getProfile(string $filename, string $path = ''): string;

Convert given image into jpeg, resize to profile resolution and return path to result image. If destination empty - will replace original file.

getStories

$imageResize->getStories(string $filename, string $path = ''): array;

Convert given image into jpeg, resize to stories resolution and slice into several stories images, if it possible. Return array of paths to result images. If destination empty - will store result file near to original file.

getReels

$imageResize->getReels(string $filename, string $path = ''): array;

Convert given image into jpeg, resize to Reels resolution and slice into several reels images, if it possible. Return array of paths to result images. If destination empty - will store result file near to original file.

getIgtvCover

$imageResize->getIgtvCover(string $filename, string $path = ''): string;

Convert given image into jpeg, resize to IGTVCover resolution and return path to result image. If destination empty - will replace original file.

Resizing post images

Different to simple images, Post resizing is tricky. Instagram allow publishing post int three resolutions: 1080x1080, 1080x565, 1080x1350. Also, there is availability to publish gallery of post images. So, to manipulate post resizing, we need additional set of methods.

getSinglePostSquare

$imageResize->getSinglePostSquare(string $filename, string $path = ''): string;

Convert given image into jpeg, resize to square post resolution and return path to result image. If destination empty - will replace original file.

getSinglePostLandscape

$imageResize->getSinglePostLandscape(string $filename, string $path = ''): string;

Convert given image into jpeg, resize to landscape post resolution and return path to result image. If destination empty - will replace original file.

getSinglePostPortrait

$imageResize->getSinglePostPortrait(string $filename, string $path = ''): string;

Convert given image into jpeg, resize to portrait post resolution and return path to result image. If destination empty - will replace original file.

getSinglePostOptimal

$imageResize->getSinglePostOptimal(string $filename, string $path = ''): string;

Convert given image into jpeg, resize to most conformity post resolution and return path to result image. If destination empty - will replace original file.

getGallerySquare

$imageResize->getGallerySquare(string $filename, string $path = ''): array;

Convert given image into jpeg, slice to several images in square post resolution and return paths to result images. If destination empty - will be stored ner to original image.

getGalleryLandscape

$imageResize->getGalleryLandscape(string $filename, string $path = ''): array;

Convert given image into jpeg, slice to several images in landscape post resolution and return paths to result images. If destination empty - will be stored ner to original image.

getGalleryPortrait

$imageResize->getGalleryPortrait(string $filename, string $path = ''): array;

Convert given image into jpeg, slice to several images in portrait post resolution and return paths to result images. If destination empty - will be stored ner to original image.

getGalleryOptimal

$imageResize->getGalleryOptimal(string $filename, string $path = ''): array;

Convert given image into jpeg, and slice to several images in most conformity post resolution, then return path to result image. If destination empty - will be stored ner to original image.

getOptimalPost

$imageResize->getOptimalPost(string $filename, string $path = ''): array;

Convert given image into jpeg, and based on image resolution just resize into optimal post resolution, or slice to several images in most conformity post resolution, then return path to result image. If destination empty - will be stored ner to original image.

antey/instagram-image 适用场景与选型建议

antey/instagram-image 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 12 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「image」 「resize」 「instagram」 「gallery」 「stories」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 antey/instagram-image 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 antey/instagram-image 我们能提供哪些服务?
定制开发 / 二次开发

基于 antey/instagram-image 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-05