dongya5893 2012-09-05 22:47 采纳率: 100%
浏览 252

PHP:从apk获取图标

finally i could get information about apk like version , package, name & ... with this source :

PHP APK Parser

icons path in apks are not unique in all apps, in some "icon.png" and other "ic_launcher.png" and in different folders. here is my problem , how i can get icon anyway, without error and bug and without tools like "apktool" and "appt" ?

actually i wanna get and view icons directly in my small site

sorry for my bad English

  • 写回答

1条回答 默认 最新

  • dongxian8048 2014-04-18 08:15
    关注

    Use this with pclzip.lib.php Library..

    <?php
    require_once 'pclzip.lib.php';
    $path = 'path/to/apk';
    $default = 'path/to/default_icon.png';
    $destination = 'path/to/destination.png';
    
    $zip = new PclZip($path);
    $data = $zip->extract(PCLZIP_OPT_BY_PREG, "/res\/drawable(|-ldpi|-mdpi|-hdpi|-xhdpi)\/(ic_launcher|icon|logo|icn|ic|i).(png|jpg|jpeg|gif)/isU", PCLZIP_OPT_PATH, './tmp', PCLZIP_OPT_REMOVE_ALL_PATH);
    
    $icn = end($data);
    $icn = $icn['filename'];
    
    //now you have path to the icon in ./tmp folder
    
    if(!empty($icn)){
    copy($icn, $destination);
    } else{
    copy($default, $destination);
    }
    
    foreach($data as $dt){
    @unlink($dt['filename']);
    }
    ?>
    

    I hope this will work for you..

    EDIT: At the time of my first answer, there wasn't a reliable method/library available. So, I created a temporary method. Which was working for me. Now, we have a better library, you should use that.

    Library: php-apk-parser by Tufan Barış YILDIRIM

    Example: ApkResource.php

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog