pic

php实现等比例不失真缩放上传图片(转)

强颜欢笑 提交于 2019-12-10 05:11:12
有时上传图片时因为图片太大了,不仅占用空间,消耗流量,而且影响浏(图片的尺寸大小不一)。下面分享一种等比例不失真缩放图片的方法,这样,不管上传的图片尺有多大,都会自动压缩到我们设置尺寸值的范围之内。经过测试,证明实用。 <?php function resizeImage($im,$maxwidth,$maxheight,$name,$filetype) { $pic_width = imagesx($im); $pic_height = imagesy($im); if(($maxwidth && $pic_width > $maxwidth) || ($maxheight && $pic_height > $maxheight)) { if($maxwidth && $pic_width>$maxwidth) { $widthratio = $maxwidth/$pic_width; $resizewidth_tag = true; } if($maxheight && $pic_height>$maxheight) { $heightratio = $maxheight/$pic_height; $resizeheight_tag = true; } if($resizewidth_tag && $resizeheight_tag) { if($widthratio<

【Python还能干嘛】爬取微信好友头像完成马赛克拼图(千图成像)~

孤者浪人 提交于 2019-12-09 21:54:40
马赛克拼图 何谓马赛克拼图(千图成像),简单来说就是将若干小图片平凑成为一张大图,如下图路飞一样,如果放大看你会发现里面都是一些海贼王里面的图片。 Our Tragets 爬取所有微信好友的头像🕺🏻🕺🏻🕺🏻 将所有微信好友头像拼凑成一张图片🏙🏙🏙 然后就可以去朋友圈愉快的装逼了🤪🤪🤪 Requirements 其实整个项目很小,项目总共代码量不过100行左右。 爬取微信头像依赖第三方库 itchat ; 马赛克拼图依赖依赖 numpy 和 PIL 库。 Content 爬取微信好友头像 我这边是用的所有微信好友头像作为的数据源,你们如果有其他的数据源也可以的,可以直接跳过这步。 爬取微信好友头像我使用的是 itchat ,里面已经有封装好了的API,直接调用就可以,将所有的好友头像保存到一个文件夹供后期使用。 代码部分 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Author : AwesomeTang # @File : Wechat_Icon.py # @Version : Python 3.7 # @Time : 2019-06-29 23:35 import os import itchat itchat.login() friends = itchat.get_friends(update=True) base

python爬虫---爬取优信二手车

北战南征 提交于 2019-12-08 22:43:14
import requests import re import redis from lxml import etree import pymysql #获取城市数据 class City(): def __init__(self): #初始化Redis连接 self.r=self.get_redis() def __call__(self, *args, **kwargs): self.get_city() # 创建数据库,减少对网站的攻击 def get_redis(self): return redis.Redis(host='127.0.0.1', port=6379, db=1) def get_city(self): # 初始的url interface_url="https://www.xin.com/apis/Ajax_common/get_home_city/" import json json_data=str(requests.get(interface_url).json()) print(json_data) print(type(json_data)) #获取城市: city_name=re.findall("'ename': '(.*?)'",json_data) # print(city_name) #遍历城市,获取城市的url for city

python爬虫:使用scrapy框架对链家租房深度爬取,并存入redis、mysql、mongodb数据库

非 Y 不嫁゛ 提交于 2019-12-08 21:40:36
1.items.py # -*- coding: utf-8 -*- # Define here the models for your scraped items # # See documentation in: # https://doc.scrapy.org/en/latest/topics/items.html import scrapy class LianjiaItem(scrapy.Item): # define the fields for your item here like: # name = scrapy.Field() pic = scrapy.Field() title = scrapy.Field() detail_url = scrapy.Field() price = scrapy.Field() publish_info = scrapy.Field() pic_list = scrapy.Field() house_code = scrapy.Field() ucid = scrapy.Field() agent_name = scrapy.Field() agent_phone = scrapy.Field() 2.lianjia.py # -*- coding: utf-8 -*- import scrapy from LianJia

XC8 error 224: illegal # directive (first line)

China☆狼群 提交于 2019-12-07 15:18:46
问题 I'm using Microchip's XC8 compiler. They want me to #include <xc.h> instead of including a chip-specific header. However, when I add this code on the first line of my code, I'm getting the error: Error [224] C:\...\main.c; 1.4 illegal "#" directive When I place a line feed before the directive, I don't get the error. Why is this? My full code: #include <xc.h> #pragma config OSC =INTIO67, WDT = OFF, LVP = OFF, PBADEN = OFF void main() { while (1); } With the line feed, the code looks just the

requests高级部分

主宰稳场 提交于 2019-12-06 13:56:15
回顾 bs4 1.实例化一个对象 2.方法或者属性进行数据提取 标签定位: soup.tagName 属性定位:soup.find('tagName',class_='xxx')/find_all() select('层级') string/text tag['src'] xpath: 属性定位://tagName[@class="xxxx"] 索引定位://tagName[1] 取文本:/text() //text() 取属性://img/@src requests高级部分 代理 cookie 验证码的识别 模拟登陆 代理 代理概念:代理服务器。 作用:接受请求==》请求转发。 代理和爬虫之间的关联: 可以使用请求转发的机制使得目的服务器接收到的请求对应ip的一个改变。 为什么要使用代理改变请求的ip地址? 爬虫程序在短时间内对指定的服务器发起了一个高频的请求,则请求对应的ip可能会被目的服务器禁止。 代理的一些基础知识: 代理的匿名度: 透明代理:目的服务器知道你使用了代理机制并且也知道你的真实IP 匿名代理:知道使用了代理机制,但是不知道你的真实ip 高匿代理:不知道使用了代理,也不知道你的真实ip 代理的类型: http https 免费代理ip: 快代理 西祠代理 www.goubanjia.com 代理精灵 需求:测试一下代理是否会生效 准备: 代理ip和端口号

How to tell clang that my LLVM Target should use 16-bit 'int'?

笑着哭i 提交于 2019-12-06 08:49:12
For my PIC Backend, I want 'int' to be 16 bits. How can I / my target tell clang what should be the size of 'int'? Defining 16-bit registers only seems not sufficient. Currently "clang -O2 -emit-llvm -target pic" converts int foo(int a, int b) { return a + b; } to this IR code, using 32-bit integers: ; ModuleID = '../test/sum.c' source_filename = "../test/sum.c" target datalayout = "e-m:e-p:16:16-i16:16-a:0:16-n16-S16" target triple = "pic" ; Function Attrs: norecurse nounwind readnone define i32 @foo(i32 %a, i32 %b) local_unnamed_addr #0 { entry: %add = add nsw i32 %b, %a ret i32 %add }

Reading state of input pins on a PIC18

房东的猫 提交于 2019-12-06 05:24:19
I have been able to get outputs working on my PIC and can make a bunch of LEDs dance on and off as I set various output latches high/low. However, I'm having a lot o difficulty reading in the state of a pin. See the code below. I set up my config, and define the TRISC as input and TRISB as output. In an infinite loop, I check to see whether RC6 is high or low, and set the entire B latch high or low depending on the result. #include <htc.h> __CONFIG(1, FOSC_IRC & FCMEN_OFF & IESO_OFF); __CONFIG(2, PWRTEN_OFF & BOREN_OFF & WDTEN_OFF); __CONFIG(3, MCLRE_OFF); __CONFIG(4, STVREN_ON & LVP_OFF &

图片轮播带小圆点选择左右切换

江枫思渺然 提交于 2019-12-06 04:14:44
图片轮播效果 导入JS html代码 <body> <div class="banner"> <div class="pic"> <div class="left"><</div> <ul> <li> <a> <img src="img/1.jpg" > </a> </li> <li> <a> <img src="img/2.jpg"> </a> </li> <li> <a> <img src="img/3.jpg"> </a> </li> <li> <a> <img src="img/4.jpg"> </a> </li> </ul> <div class="right">></div> </div> <div class="dot"> <ul> <li></li> <li></li> <li></li> <li></li> </ul> </div> </div> </body> css代码 <style> *{ margin: 0px; padding: 0px; } .banner{ width: 790px; height: 340px; background-color: #fed93a; margin-top: 20px; margin-left: 20px; margin: 0px auto; overflow: hidden; position: relative;

js基础【用数组 点击按钮切换图片】

£可爱£侵袭症+ 提交于 2019-12-06 03:42:51
<body> <img src="img/dm.jpeg" alt="" id="pic"><br> <input type="button" value="下一张" id="btn"> <p id="txt">显示的是img/1.jpg</p> <script> var ary = ['img/dm.jpeg','img/dm1.jpeg','img/dm2.jpg','img/dm3.jpg','img/gg.jpg']; var oBtn = document.getElementById('btn'), oPic = document.getElementById('pic'), oTxt = document.getElementById('txt'); var n = 0; oBtn.onclick = function(){ n = n + 1; if(n == ary.length){ n = 0; } oPic.src = ary[n]; oTxt.innerHTML = '显示的是'+ ary[n]; } </script> </body> 实现效果如下 来源: CSDN 作者: 国产菇凉 链接: https://blog.csdn.net/weixin_42402845/article/details/94890676